I’m sure this is simple, but I am having trouble opening and populating a screen to edit the User entity. What is the proper way to have this screen open from the main menu and populate and then save the User object? I have a screen I called Profile Edit that looks like this right now:
ProfileEdit.java:
@UiController("ws_Profile.edit")
@UiDescriptor("profile-edit.xml")
public class ProfileEdit extends Screen {
@Inject
private InstanceLoader<User> profileDl;
@Inject
private UserSession userSession;
@Subscribe
public void onAfterInit(AfterInitEvent event) {
User user = userSession.getUser();
System.out.println("User = " + user.getName());
}
}
profile-edit.xml:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<window xmlns="http://schemas.haulmont.com/cuba/screen/window.xsd"
caption="msg://caption"
messagesPack="com.thrivalist.workscape.web.screens.profile">
<data>
<instance id="profileDc"
class="com.haulmont.cuba.security.entity.User"
view="user.edit">
<loader id = "profileDl"/>
</instance>
</data>
<layout>
<grid align="MIDDLE_CENTER"
spacing="true">
<columns count="2"/>
<rows>
<row>
<label value="First Name"/>
<textField id="firstName"
required="true"/>
</row>
<row>
<label value="Middle Name"/>
<textField id="middleName"/>
</row>
<row>
<label value="Last Name"/>
<textField id="lastName"
required="true"/>
</row>
<row>
<label value="Email"/>
<textField id="email"
required="true"/>
</row>
<row>
<hbox align="MIDDLE_CENTER"
colspan="2"
spacing="true">
<button id="okBtn"
align="TOP_RIGHT"
caption="OK"/>
<button id="cancelBtn"
caption="Cancel"/>
</hbox>
</row>
</rows>
</grid>
</layout>
</window>