Opening Views
- Create a new view, e.g. CustomerView and add a few UI components.
- Add a button in MainView and register a buttonClickHandler event.
- In the code view, move the cursor under the generated Button.ClickEvent Handler.
- Under Palette click Navigation.
- In the following Navigation wizard, under View to open, select Customer View out.
- In the URL field, enter a sub path (URI) through which the view is to be accessible at runtime, e.g. customer.
Result:
private void button_buttonClick(Button.ClickEvent event) { Navigation.to("customer").navigate(); }
Note:
- If the view that is to be called is not yet registered in the Navigator, it will be automatically registered by the wizard.
- Only views that are registered in the Navigator can be invoked using the Navaigation.to() method.
- The Navigation wizard works bidirectionally. By clicking the icon in the code editor, you can reopen the Navigator wizard.
Passing parameters
- In the Navigation wizard, click Add to add the parameter you want to pass to the view that is to be invoked.
- Under Parameters > Value, enter the parameter you want to pass; e.g., the username string, and press Enter.
- Under Name, specify how you want to call the parameter that is passed to the view, e.g. username.
- Click OK.
- Click Save.
Result:
In the current view
private void button_buttonClick(Button.ClickEvent event) { Navigation.to("customer").parameter("username", username).navigate(); }
In the invoked view - When the parameters that are to be passed are saved, they are automatically defined in the target class.
@NavigationParameter private String username; /** * */ public CustomerView() { super(); this.initUI(); } @Override public void enter(ViewChangeListener.ViewChangeEvent event) { super.enter(event); this.username = Navigation.getParameter(event, "username", String.class); }
Note:
- Any variables, method calls, and objects; e.g., UI components, can be used as parameters..
- The parameters are passed via the session array.
- Strings must be enclosed in quotes.
- The arguments that are deleted later in the Navigation wizard are not automatically deleted in the invoked view.
XDEV Software Corp. - One Embarcadero Center, San Francisco, CA 94111, US
Copyright © 2015. XDEV Software Corp. All rights reserved.