AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / Desarrollar una aplicación o un sitio web / Controles, ventanas y páginas / Página / Programación
  • Default events
  • Optional events
  • Optional events for managing the off-line mode
  • Optional event to manage the navigation history
WINDEV
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
Default events
WEBDEV - Código ServidorWEBDEV - Código NavegadorWindowsLinux The following events appear by default in the WEBDEV code editor:
EventRuntime condition
Global declarations
(Server code)
Declaration of variables global to the page. This is the first code run when opening the page.
Initialization
(Server code)
Executed when the page is opened.
The events are run in the following order:
  • Initializing the page controls.
  • Initializing the page.
Loading (onload) of the page
(Browser code)
Browser code run when the page is displayed in the browser (performed by PageDisplay or PageRefresh for example).
Unload (onunload) page
(Browser code)
Browser code run when a new page is displayed in the browser.
Refreshing the page data
(Server code)
Event available only if the automatic data refresh was defined for the page (see Refreshing the page data). This event is executed when the page is refreshed. It can be used, for example, to update desired fields: filling a list, etc. This event is an AJAX event.
If this event returns False, the "After refreshing the page data (Browser code)" event is not run.
Request for refreshing the display
(Server code)
Enables you to group together the code for updating page fields: field content, status (visible, grayed, etc.), label to be updated, etc.
This event can receive parameters. Simply declare a procedure in the event. For example:
// Request for refreshing the display 
PROCEDURE AskForRefresh(RefreshType is boolean)
This event is started upon request by the following functions:
When these functions are called, you can specify the value of the parameters expected by the event.
After refreshing the page data
(Browser code)
Event available only if the automatic data refresh was defined for the page (see Refreshing the page data).
This event is run after the "Refreshing the page data (server code)". It is used to perform an additional process on the browser. If the "Refreshing the page data (Server code)" returns False, the event "After refreshing the page data (Browser code)" event is not run.
Close the page
(Server code)
Executed when the page is closed.
Synchronization of the page
(Server code)
Server code used to manage the page synchronization when clicking the browser "Back" button. For more details, see Configuring the browser "Back" button.

Remark: In a static page, only browser codes are available.
PHP In PHP, the following WLanguage events are associated with pages:
EventRuntime condition
Declaration of global variables (Server code)Declaration of variables global to the page. This is the first code run when opening the page.
Initialization (Server code)Case 1: Page with context:
Executed only once, the first time the page is displayed, to initialize the context.
The events are run in the following order:
  • Initializing the page controls.
  • Initializing the page.
Case 2: Page without context:
Run whenever the page is displayed. Used to run a process whenever the server redisplays the page (a process used to check whether the Web user is identified by his login for example).
The events are run in the following order:
  • Initializing the page controls.
  • Initializing the page.
1st display of the page (Server code)For the PHP pages without context
Executed only once, the first time the page is displayed.
The events are run in the following order:
  • Initializing the page controls.
  • Initializing the page.
Whenever the page is displayed (Server code)For the PHP pages with context
Run whenever the page is displayed. Used to run a process whenever the server redisplays the page (a process used to check whether the Web user is identified by his login for example).
Reminder: The page "Initialization" event is executed only once, when the page is first displayed, to initialize the context.
For an AJAX page, this event is run for each request made to the server.
Load (onload) page (Browser code)Browser code run when the page is displayed in the browser (performed by PageDisplay or PageRefresh for example).
Unloading (onunload) the page (Browser code)Browser code run when a new page is displayed in the browser.

For example, in a PHP page without context:
  • During the initialization, a Combo Box control that lists the titles is filled with "Madam"+ CR + "Mister".
  • During the first display, the default title is selected ("Mister").
For example, in a PHP page with context:
  • During the initialization, a Combo Box control that lists the titles is filled with "Madam"+ CR + "Mister" and the default title is selected ("Mister").
  • During each display, a test about the consistency of control or about the consistency of control update is run (counter of visits, ...).
Optional events
Several optional events can be added.
To add an optional event:
  1. Select the desired control.
  2. Display the code window of this control (F2 key).
  3. Click the link "Add other events to xxx" at the bottom of the window code, after the last event.
  4. All the optional events available for the control are displayed.
  5. Check the optional event to add and validate.
    Note: Several optional events can be selected.
  6. The selected optional event is automatically added to the events managed by the control.
To disable an optional event, simply perform the same operations to display the list of optional events. Then simply uncheck the optional events to delete.
Note: If the deactivated code contains WLanguage code, this code is automatically deleted..
You can manage, for example:
  • left mouse button down, up, double click,
  • right button down, up, with double click, ...
For more details, see the Optional events.

Optional events for managing the off-line mode

Several optional events can be used to optimize the management of offline sites:
EventRuntime condition
Switch to off-line mode (Browser code)Executed when switching to off-line mode.
Switch to on-line mode (Browser code)Executed when switching to on-line mode.
Whenever the status of the HTML cache changes (Browser code)This event is used to check what happens when the page is loaded. This event is called whenever the cache is checked.
The following command line is used to retrieve the actions performed by the browser:
Trace(JSInfoEvent("type"))
You have the ability to find out:
  • whether the browser is currently updating the cache,
  • whether an error occurs
  • whether the update of the cache is completed
  • whether no update must be performed, ....

Optional event to manage the navigation history

To optimize management of the previous/next buttons, a specific optional event is available: "Move in navigation history (onpopstate)"..
This event expects the data to display, as parameter. This data was stored in the history by BrowserHistoryAdd and BrowserHistoryModify.
If the Web user goes back to an entry in the history, the stored data will be transmitted to the "Move in the navigation history" event (optional page event). This event must process the data in order to restore the page status. This process must be associated with a procedure that expects the transmitted data as parameter:
// Evénement "Déplacement dans l'historique de navigation (onpopstate)"
PROCEDURE <NomProcédure>(<Données>)
Example: This example adds the page into the history and stores the insertion time. Going back to the previous history page displays the time.
x is Variant
x.Heure = TimeSys()
BrowserHistoryAdd(x, MyPage.Titre, "#avant") 

x.Heure = TimeSys()
BrowserHistoryAdd(x, MyPage.Titre, "#apres")
// Evénement "Déplacement dans l'historique de navigation (onpopstate)" 
PROCEDURE TraitementHistorique(stEtat)
Info(stEtat.Heure)
Note: Depending on the browser, the "Move to browsing history (onpopstate)" event is also executed when the page is loaded, and when the page is returned to its initial display.. In this case, the <Data> parameter transmitted to the event corresponds to Null.
Versión mínima requerida
  • Versión 10
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 30/09/2024

Señalar un error o enviar una sugerencia | Ayuda local