ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / Developing an application or website / Controls, windows and pages / Page / Programming
  • Default events
  • Optional events
  • Optional events for managing the off-line mode
  • Optional event to manage the navigation history
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Default events
WEBDEV - Server codeWEBDEV - Browser codeWindowsLinux 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 is used for example to refresh the desired controls: filling a list, ... This 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)
Contains all the code for refreshing the page controls: content of controls, state (visible, grayed, etc.), caption to refresh, 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)
Run 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 Managing the browser "Back" button.

Remark: Only the browser codes are available in a static page.
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, the first time the page is 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, ...).
Related Examples:
WW_Forum_PHP Complete examples (WEBDEV): WW_Forum_PHP
[ + ] This example proposes the main features of a user forum (creation of forums, topics and messages, moderator, search, etc.)

Some of the features used by WW_FORUM_PHP:
- Rich control
- AJAX
-...
WW_Blogs_php Complete examples (WEBDEV): WW_Blogs_php
[ + ] This example is a PHP site created with WEBDEV for managing blogs.
A blog is a log or a diary on an Internet site.
It can be consulted by everyone and everyone can write his own comments.
The author of the blog writes messages whenever he wants to.
You have the ability to format the text, to include images, notes, and so on.
Furthermore, each blog can be exported in RSS.
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.
    Remark: You can select several optional events.
  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.
Remark: If the disabled 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

A specific optional event is available to optimize the management of Back/Next buttons: "Move into the 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:
// Event "Move in the navigation history (onpopstate)"
PROCEDURE <ProcedureName>(<Data>)
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.Time = TimeSys()
BrowserHistoryAdd(x, MyPage.Title, "#before")
 
x.Time = TimeSys()
BrowserHistoryAdd(x, MyPage.Title, "#after")
// Event "Move in the navigation history (onpopstate)"
PROCÉDURE ProcessHistory(stStatus)
Info(stStatus.Time)
Remark: Depending on the browser, the event "Move in the navigation history (onpopstate)" is also run when loading the page and when going back to the initial page display. In this case, the <Data> parameter transmitted to the event corresponds to Null.
Minimum version required
  • Version 10
Comments
Click [Add] to post a comment

Last update: 06/10/2024

Send a report | Local help