|
|
|
|
|
- Overview
- Using planes
- Loading effects
- Delayed display
- Using popups
- Authentication
- Managing the Back key
A "Single Page App" is a Web application (Internet or Intranet) whose all pages are grouped in a single page. With WEBDEV, this type of application can be easily re-used via planes, popups, cookies, etc. From version 22, WEBDEV allows you to use planes in a Web page. The use of maps avoids the need for alternate-reverses with the server each time a page is changed, making applications appear smoother and more "native". The operating mode of planes in WEBDEV is similar to the operating mode of planes in WINDEV/WINDEV Mobile. However, some differences can be noticed: - Drawings are available independently for each each container element the page, a layout area, a rich text area, a cell, etc. This feature allows you to perform several display combinations.
- The management of planes must be explicitly enabled in the element. From the description of container element, "UI" tab, all you have to do is enable the option "Enable the management of planes".
- There is no plane "0".
- In WINDEV, a control that must be displayed on all planes is linked to plane "0". It is the default plane, that is always visible.
- In WEBDEV, a control that must always be visible must be explicitly placed on all planes with content.
- The plane of a control cannot be modified programmatically. The association between a control and one or more planes is performed in edit only.
To change the displayed plane, use the Plane property on the container element. // Go to Dashboard plane CELL_Plane.Plane = 2 Loading effects One or more effects can occur when going from a plane to another one. The effects can be defined from the description window of element, "Style" tab. Effects can be defined: - on the container element that manages the plane. All you have to do is add an effect with an adapted release (change plane, go to previous plane, etc.). 6 effects are available to manage the change of plane: plane swipe, blur plane sequence, plane fade-in (%), plane overlap, plan fold, plane flip.
- on the control found in the plane. All you have to do is add an effect with trigger of appearance (display the plane where the control is found) or disappearance (display another plane).
Delayed display By default, the page is entirely loaded by the browser, with the full content of each plane. In an application where all elements are found in a single page, this operating mode can significantly slow down the page display. To avoid this slowdown, the load of planes can be delayed: the plane content will be effectively loaded when a request for loading the plane is performed: - when loading the page if the plane is displayed by default,
- when changing the plane via the Plane property.
To delay the loading of planes, simply check "Delayed loading of plane content" in the "UI" tab of the container element description. This option enables two new events "Delayed plane load", available in the code editor: - an AJAX server event called when a plane is displayed,
- a browser event called once the plane is loaded.
The plane must be programmed in these events to be actually loaded. // -- Event "Defer loading of a plan (server)" // According to plane SWITCH MySelf.Plane // Dashboard CASE 2 LoadWidget() LoadChart() // Products CASE 3 ... END In these two events, the number of the plane that has just been displayed is available via the Plane property. If you want to find out the number of the plane that was displayed before, all you have to do is store it in a variable. In order for the Web user to have the sensation to use a native application, you have the ability to use dialog boxes, to propose an authentication for example. To obtain this type of UI with WEBDEV, simply use Popup pages. To create a Popup page, go to the "Creation" tab, "Containers" group and click "Popup". A Popup page is displayed from a browser code, via PopupDisplay. This function expects the name of the popup to display and its position (specific position or position relative to a control) as parameter. // Displays the connection popup PopupDisplay(POPUP_Connection, popupTopLeft, 0, 0) For more details, see The Popup control. The authentication is a major element in a Web application. Of course, authentication must not be performed in a browser event: a malicious person could all too easily bypass authentication. However, you should avoid using server returns in a Single Page App application. Therefore, an AJAX process must be used: - by calling the WLanguage AJAXExecute function.
// Checks the information // for user authentication let sConnectionIdentifier = AJAXExécute(CheckConnectionInformation, EDT_Login, EDT_Password) - by enabling the AJAX mode of connection button (if the connection code is directly found in the button).
In order for the user to avoid typing his identifiers at each connection, his authentication can be stored via a cookie. During the next application start, if the cookie is found and correct, the user will be automatically authenticated and he will access
the application content directly. To perform this behavior, you must: - Store a cookie during the authentication via CookieWrite. The cookie does not store the username directly but a random value generated during his connection and that was stored in database.
PROCEDURE CheckConnectionInformation(...
sLogin is string, sPassword is string)
HReadSeekFirst(User, Login, sLogin)
...
User.ConnectionGUID = GetGUID()
HModify(User)
RETURN User.ConnectionGUID
//-- Browser code of connection button // Generates a cookie if necessary IF CBOX_RememberMe THEN CookieWrite("Connection", sConnectionIdentifier) END - In the page load event (OnLoad), if the cookie is found, the authentication popup is not displayed and the user is connected directly.
//-- Browser code to load a page let sConnectionGUID = CookieRead("Connection") // Finds the user let bKnownUser = AJAXExecute(CheckConnectionInformation, sConnectionGUID) //-- Server procedure PROCEDURE CheckConnectionIdentifier(LOCAL sConnectionIdentifier) // Finds the user HReadSeekFirst(User, ConnectionGUID, sConnectionIdentifier) RETURN HFound(User)
Tip: For a Web application with authentication, don't forget to use an HTTPS connection so that login and password cannot be intercepted. When the Web user clicks the browser "Back" button, the browser goes back to the previous page. A Single Page App includes a single page! Therefore, the Back button goes back to the page displayed before starting the application! WEBDEV allows you to assign a standard behavior to the Back button. - The navigation history is automatically filled and it intercepts the "Back" (or "Next") event to control the display.
- The page of Single Page App application is displayed in its previous status.
This management is performed programmatically: - via the functions:
| | BrowserHistoryAdd | Adds an entry into the history of navigation by associating data. This data will be transmitted when going back to this entry. | BrowserHistoryModify | Modifies the data of current entry in the navigation history. This data will be transmitted when going back to the current entry. |
- via the optional event "Move into the navigation history" called when the user clicks "Back" or "Next". For more details, see Optional events associated with pages
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|