Cannot remove default field from User.edit

Hello everyone!
I found a new trouble in my project - I cannot remove a field from field group column “Time Zone” at ExtUserEdit screen.
Because it should be changed on customTimeZone
Here the base project with this thing
examplePr.zip (89.9 KB)

I will be very grateful for your replying

Regards, Oleg

Hi,
Thank you for your sample project.
It seems, you can simply customize User-editor screen instead of creating a new screens for ExtUser. How to do it is described here: Extending Screens - CUBA Platform. Developer’s Manual

  1. In Studio start new screen wizard and select “Extend an existing screen”

  2. On the next step select user-edit.xml
    image

  3. As result. Two sources will be created: ExtUserEditor.java and ext-user-edit.xml

  4. Then we need to remove the timeZone field from the edit-screen.
    We cannot remove anything from the parent screen using XML. Moreover the timeZone field is custom and tuned in the screen controller. So lets modify ExtUserEditor.java

public class ExtUserEditor extends UserEditor {
    @Override
    public void init(Map<String, Object> params) {
        super.init(params);
        fieldGroupRight.removeField("timeZone");
    }
}
  1. Now we need a component for your custom TimeZone. The most simple way is just to add the property to fieldGroup. Modify ext-user-edit-xml as follows:
    You can also make this field custom and adjust it in the screen controller. How to do it see the code of the parent UserEditor class.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<window xmlns="http://schemas.haulmont.com/cuba/window.xsd" class="com.company.userscreen715.web.screens.ExtUserEditor"
        messagesPack="com.company.userscreen715.web.screens" xmlns:ext="http://schemas.haulmont.com/cuba/window-ext.xsd"
        extends="com/haulmont/cuba/gui/app/security/user/edit/user-edit.xml">
    <dsContext>
        <datasource id="userDs" class="com.company.userscreen715.entity.ExtUser" view="extUser-edit"/>
    </dsContext>
    <layout>
        <groupBox id="propertiesBox">
            <grid id="propertiesGrid">
                <rows>
                    <row id="propertiesRow">
                        <fieldGroup id="fieldGroupRight">
                            <column>
                                <field property="customTimeZone" id="ctzField" visible="true"/>
                            </column>
                        </fieldGroup>
                    </row>
                </rows>
            </grid>
        </groupBox>
        <label value="extuserscreen1"/>
    </layout>
</window>
  1. Pay attention to “userDs” above. It should contain the link to custom TimeZone, so change “class” to ExtUser and do not forget to create the corresponding view.

Regards.

1 Like