Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for initial layout in MainView #2213

Closed
glebfox opened this issue Sep 8, 2023 · 1 comment
Closed

Support for initial layout in MainView #2213

glebfox opened this issue Sep 8, 2023 · 1 comment
Assignees
Milestone

Comments

@glebfox
Copy link
Contributor

glebfox commented Sep 8, 2023

In case no view is opened, it is required to display some default layout in the Main View, e.g. with logo or dash board.


Let's add initialLayout element to the main view, so if no view is opened, its content is displayed. The logic of handling switching between a view and initial layout must be located in the base class.

Solution

Optional <initialLayout> element is introduced inside <appLayout>, e.g.:

<appLayout>
    ...
    <initialLayout>
        <textField id="textField" label="TextField" clearButtonVisible="true"/>
    </initialLayout>
</appLayout>

When added in XML, the root <initialLayout> element effectively is VerticalLayout.

Alternatively StandardMainView's java API can be used to set/get initial layout:

  • StandardMainView#getInitialLayout - returns root component of initial layout
  • StandardMainView#setInitialLayout - sets a component that will be an initial layout

Components inside <initialLayout> can be injected in the MainView, e.g.:

@Route("")
@ViewController("MainView")
@ViewDescriptor("main-view.xml")
public class MainView extends StandardMainView {

    @ViewComponent
    private TypedTextField<String> textField;

    @Subscribe
    public void onInit(final InitEvent event) {
        textField.setValue("Programmatic Value");
        textField.setWidth("25em");
    }

    @Subscribe("textField")
    public void onTextFieldTypedValueChange(final TypedValueChangeEvent<TypedTextField<String>, String> event) {
        Notification.show(event.getValue());
    }
}
@glebfox glebfox added candidate Possible candidate for future releases in: flowui labels Sep 8, 2023
@glebfox glebfox self-assigned this Oct 29, 2023
@glebfox glebfox removed the candidate Possible candidate for future releases label Oct 30, 2023
@knstvk knstvk added this to February 2024 release in Jmix Roadmap Nov 7, 2023
@glebfox
Copy link
Contributor Author

glebfox commented Nov 7, 2023

@knstvk knstvk changed the title [MainView] Support for initial layout Support for initial layout in MainView Nov 14, 2023
@glebfox glebfox closed this as completed Dec 25, 2023
@gorbunkov gorbunkov added this to the 2.2.0 milestone Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Jmix Roadmap
February 2024 release 2.2
Status: Done
Development

No branches or pull requests

2 participants