- Using planes
- Loading effects
- Delayed display
- Using popups
- 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 planes avoids the need to go back and forth with the server each time the page is changed: the applications are more fluid, 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:
- The planes are available independently for each container element: the page, a layout area, a rich text area, a cell. 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 through programming. 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.
// Passage au plan Tableau de bord
CELL_Plan.Plan = 2
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).
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 slowness, the planes can be loaded in delayed mode: 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.
// -- Evénement "Chargement différé d'un plan (serveur)"
// Selon le plan
// Tableau de bord
In these two events, the number of the plane that has just been displayed is available via the Plane
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.
// Affiche la popup de connexion
PopupDisplay(POPUP_Connexion, popupTopLeft, 0, 0)
For more details, see The Popup control
The authentication is a major element in a Web application.
The authentication must not be performed in a browser event: a malicious person could easily bypass the 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.
// Vérifie les informations
// d'authentification de l'utilisateur
let sIdentifiantConnexion = AJAXExécute(VérifieInformationsConnexion, SAI_Login, SAI_Motdepasse)
- 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.
//-- Procédure serveur exécutée via AjaxExécute
sLogin is string, sMotDePasse is string)
// Recherche l'utilisateur en base
HReadSeekFirst(Utilisateur, Login, sLogin)
// Mémorise un identifiant de connexion
Utilisateur.GUIDConnexion = GetGUID()
// L'identifiant est renvoyé (pour être mémorisé)
//-- Code navigateur du bouton de connexion
// Génère un cookie si besoin
IF INT_SeSouvenirDeMoi THEN
- In the page load event (OnLoad), if the cookie is found, the authentication popup is not displayed and the user is connected directly.
//-- Code navigateur de chargement de la page
let sGUIDConnexion = CookieRead("Connexion")
// Recherche l'utilisateur
let bUtilisateurConnu = AJAXExécute(VérifieIdentifiantConnexion, sGUIDConnexion)
//-- Procédure serveur
PROCÉDURE VérifieIdentifiantConnexion(LOCAL sIdentifiantConnexion)
// Recherche l'utilisateur
HReadSeekFirst(Utilisateur, GUIDConnexion, sIdentifiantConnexion)
Tip: For a Web application with authentication, don't forget to use an HTTPS connection in order for the login and password not to 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 through programming:
- 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