Got an error while extending login window

Hi Guys,
I got a requirement to add a button ‘reset password’ to the login window. I think document about extend screen is quite clear. But the requirement is quite odd, the customer wants this button next to ‘remember me’. I tried to use an HBOX to wrap origin ‘remember me’ checkbox and add a new linked button next to it as below:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <window xmlns="http://schemas.haulmont.com/cuba/window.xsd"
        class="org.kuroro2121.uidemo.web.demo.ExtAppLoginWindow"
        extends="/com/haulmont/cuba/web/app/loginwindow/loginwindow.xml"
        messagesPack="org.kuroro2121.uidemo.web.demo"
        xmlns:ext="http://schemas.haulmont.com/cuba/window-ext.xsd">
    <layout>
        <vbox id="loginWrapper">
            <vbox id="loginMainBox">
                <grid id="loginFormLayout">
                    <columns>
                        <column id="loginFormCaptionColumn"/>
                        <column id="loginFormFieldColumn"/>
                    </columns>
                    <rows>
                        <row id="rememberMeRow" ext:index="3">
                            <hbox ext:index="1">
                                <checkBox id="rememberMeCheckBox"
                                          align="MIDDLE_CENTER"
                                          caption="mainMsg://loginWindow.rememberMe"/>
                                <linkButton align="MIDDLE_CENTER"
                                            caption="msg://forgetPassword"/>
                            </hbox>
                        </row>
                    </rows>
                </grid>
            </vbox>
        </vbox>
    </layout>
</window> 

I can use the studio to generate this code, but I can’t reopen and edit it. And platform raised an error ‘Grid column count is less than number of components in grid row’, obviously, it treats my HBOX as a new column not override it. Do I miss anything? Can you please help me to make this work?

Hey,
You can just create your own implementation of the Login Window. See this.
Copy the markup from the original Login Window, add your own elements without using extend.
The screen controller can be inherited from AppLoginWindow.

Hi,

I would recommend you to add a link button programmatically. The idea is that you remove the rememberMeCheckBox from the grid, wrap the rememberMeCheckBox and the link button with the HBox and place this HBox to the previous place of the rememberMeCheckBox. For example:

@Override
public void init(Map<String, Object> params) {
    super.init(params);

    Component parent = rememberMeCheckBox.getParent();
    if (parent instanceof GridLayout) {
        GridLayout gridLayout = (GridLayout) parent;
        GridLayout.Area area = gridLayout.getComponentArea(rememberMeCheckBox);

        gridLayout.remove(rememberMeCheckBox);

        HBoxLayout hbox = componentsFactory.createComponent(HBoxLayout.class);

        rememberMeCheckBox.setAlignment(Alignment.BOTTOM_LEFT);
        hbox.add(rememberMeCheckBox);

        LinkButton linkButton = componentsFactory.createComponent(LinkButton.class);
        linkButton.setCaption("Reset password");
        linkButton.setAlignment(Alignment.BOTTOM_RIGHT);

        hbox.add(linkButton);

        gridLayout.add(hbox, area.getColumn1(), area.getRow1(), area.getColumn2(), area.getRow2());
    }
}

Regards,
Gleb

Thanks a lot. I think this way is much powerful. I will try it in another case.

Thanks for reminding me that I can totally replace this screen.