hub.eb?material_id=644

Navigation Basics


Every Form has a unique URL based on its name. The URL of a Form follows the pattern: <domain name>/<webapp name>/<form name>.eb, for example, www.myDomain.com/ebase/logon.eb.

Navigating to a Form opens its first Page. A Form’s first Page can be configured in the Form Properties dialog, opened by clicking on the Form Properties  button in the Form Editor’s toolbar.

A Page in a Form can be navigated to via the Verj.io JavaScript API forms.gotoPage(Page) function.

This script could be added to the On Click Event of a Button or Hyperlink Control to navigate to the Page when clicked. To dynamically decide to go to a different Page in a Form instead of its first Page, gotoPage(…) can be executed in the Form’s beforeForm Event.

Pages in other Forms cannot be directly navigated to in this way, first you must navigate to the Form. The gotoForm(Form) API function works in a similar way to the gotoPage() function, changing to the first Page of the specified Form rather than to a Page in the current Form.

As each Form has its own URL a hyperlink can be used to navigate to a Form by setting its External URL property to <form name>.eb:

The URL of a Hyperlink Control can also be dynamically changed in scripts using the controls interface:

Steps


1

If you haven't already, complete the Steps in the Developing with Themes Tutorial before starting these Steps.

Switch to your verjioTutorials Workspace if you haven’t already:

  1. Click File > Switch Workspace.
  2. Select verjioTutorials
  3. Click OK.
2

Create a new Project called verjioBasics, if it doesn't already exist:

  1. Click New .
  2. Select Project.
  3. Select the Create Project tab.
  4. Choose Empty Project.
  5. Name your project verjioBasics.
  6. Click Finish.
3

Create a Form called navigationBasics in a navigationBasics Folder in this Project:

  1. Right-click on the verjioBasics Project and select New > Folder.
  2. Name the Folder navigationBasics.
  3. Right-click on the navigationBasics Folder and select New > Form.
  4. Name the Form navigationBasics.
  5. Click OK.
4

Add a second Page to navigationBasics:

  1. In the Pages view, click New .
  2. Name the new page Page_2.
5

Create a main section for Page_1 with a button to navigate to Page_2:

  1. Select Page_1 from the  Pages View.
  2. Add a  Main by dragging it from the Palette into the Outline View as a child of the  Page_1 Page Control.
  3. Add a  Bootstrap Container as a child of the Main.
  4. Add a  Heading as a child of the  Main Bootstrap Container and write Form 1, Page 1 in the Create New Control dialog.
  5. Add a  Button underneath the  Heading and write Goto Page 2 in the Create New Control dialog.

At this point, your Outline view should look like this:

6

Add an event to navigate to Page_2 when the Goto Page 2 button is clicked:

  1. Select the Page_1 from the Pages view.
  2. Right-click on the Goto Page 2 Button Control and select  Events.
  3. In the Events dialog, click Create New Script and name it gotoPage2.
  4. In the new script paste the following code:
    form.gotoPage(pages.Page_2);
  5. Save the script.
7

Create a main section for Page_2 with a button to navigate (as yet uncreated Form): navigationBasics2

  1. Select Page_2 from the Pages View in navigationBasics.
  2. Add a  Main by dragging it from the Palette into the Outline View as a child of the  Page_2 Page Control.
  3. Add a  Bootstrap Container as a child of the Main.
  4. Add a  Heading as a child of the  Main Bootstrap Container and write Form 1, Page 2 in the Create New Control dialog.
  5. Add a  Hyperlink underneath the  Heading and write To Form 2 in the Create New Control dialog.

At this point, your Outline view should look like this:

8

Add an URL to the To Form 2 hyperlink to navigate to Form navigationBasics2

  1. Select the Page_2 from the Pages view in navigationBasics.
  2. Click on the To Form 2 Hyperlink Control to select it.
  3. In the Properties View tick the Link is external property.
  4. In the Properties View write navigationBasics2.eb in the External URL property.

The Properties View should look like this:

9

Create a second Form called navigationBasics2 in the navigationBasics Folder:

  1. Right click on the navigationBasics Folder and select New > Form.
  2. Name the Form navigationBasics2.
  3. Click OK.
10

Create a main section for Page_1 with a hyperlink to navigate back to Form navigationBasics

  1. Select Page_1 from the Pages View in navigationBasics2.
  2. Add a  Main by dragging it from the Palette into the Outline View as a child of the  Page_1 Page Control.
  3. Add a  Bootstrap Container as a child of the Main.
  4. Add a  Heading as a child of the  Main Bootstrap Container and write Form 2, Page 1 in the Create New Control dialog.
  5. Add a  Hyperlink underneath the  Heading and write Goto Form 1 in the Create New Control dialog.

At this point, your Outline view should look like this:

11

Add an event to navigate to Form navigationBasics when the Goto Form 1 hyperlink is clicked:

  1. Select the Page_1 from the Pages view in navigationBasics2.
  2. Click on the Goto Form 1 Hyperlink Control to select it.
  3. In the  Properties View change the Control name property to toForm1.
  4. In the Properties View click on the On Click property button.
  5. In the resulting Configure - on click event dialog, click Create New Script and name it hyperlinkToForm1.
  6. In the new script paste the following code:
    controls.toForm1.useExternalURL = true;
    controls.toForm1.href = "navigationBasics.eb";
  7. Save the script.
12

Test the Form in your browser:

  1. Press the Save All  button in the main toolbar. 
  2. Click the Test  button in the main toolbar and press Submit in the resulting dialog.
  3. Navigate around the pages by clicking on the buttons and hyperlinks we have created.

Related