Using parameters

JBStrap's SoftLink solution enables you to use parameters. SoftLink parameters must be specified in runtime. The specified parameters are displayed unencrypted in the page URL. You can also programmatically read out the parameters and use them when building the page.

Modify the code for the ExamplePage in the above example so that the name specified in the parameter is displayed in the input field:

To read the URL parameter value, use the getUrlParameter() method.

Specify the following URL to open the page:

http://example.com/exampleApp/# examplePage &name=John

The input field accepts the value of the name parameter.

If you specify an invalid parameter, the getUrlParameter() method returns NULL.

You can also programmatically specify a parameter value. The addUrlParameter() method is used to set a URL parameter. In the following example, we modify the previously created code so that the name URL parameter accepts the text in the input field.

If the parameter value to be specified is NULL, the parameter is not included in the URL parameters. If it was earlier, however, the parameter is deleted. This is how you can remove parameters from the code.

Registering a page

Pages to be used by the application need to be created first, then assigned to the framework by the JBStrap addPage() method to the Startup class (read more on this in the ApplicationStartup chapter).

In the above code snippet we used the following parameters to create a page:

  • pageId: During navigation, this page ID can be used to reference the pages. These pageIds are our navigation endpoints.
  • ExampleUI: When creating pages, the UI where the page will be displayed must be specified. It is possible to display the page on multiple UIs. If a page is to be displayed on multiple UIs, then the page must have multiple, unique page IDs.
  • ExamplePage: The class representing the page

You can place additional parameters in the URL when using a SoftLink. Pages can use these parameters. The BasePage class handles SoftLink URL parameters, so you only have to place or read the parameter(s) you want. Adding a URL parameter to the SoftLink:

Reading an URL parameter from the page address:

You can include this in a button click event handler or a page build method.

If you use custom parameters in the SoftLink, keep in mind that these parameters are not encrypted and can be easily modified, as they are just plain texts in the address bar. We recommend that you only use parameters that do not contain sensitive information, or do not contain information that may pose a security risk to the application.