Occurs the first time the page is accessed. Server-side objects are created and page variables filled before this event is triggered.
psPage object
None
Boolean. You must include a return value in the event script.
This event is the place to include initialization that you want to have occur only the first time the page is accessed. For example, you could use this event to call webdw.Retrieve to fetch data, or webdw.InsertRow to start off in data entry mode. It is the equivalent of the PowerBuilder Open event.
If binding is not selected for a Web DataWindow control, you should call either Retrieve or Insert in the FirstTime event. If the control is using a stateless server component and Retrieve is called once, the server automatically re-performs the retrieve, using the retrieval arguments that were passed to Retrieve during the binding phase.
Error processing Because this event is triggered before generation occurs, psDocument.Write cannot be used for reporting errors. Instead, you can use the ReportError method on the psPage object to trigger the ServerError event. The error will then be added to the error log, depending on the ServerError return value.
This example adds an item to the user’s shopping cart if the value of the action page parameter (passed from a linking page) is "add". It then retrieves information from the user’s shopping cart in a DataWindow:
if (action == "add") {
n_cart.additem(user, cd_id);
}
dw_cart.Retrieve(user);
The following example shows code placed in the FirstTime event of a page that is loaded from a logon screen when the user enters a password that is incorrect. The showErrorsOnPage property is set to false because the error will be displayed at a precise location on the page by calling WriteErrorsToDocument in a server-side script. The error message needs to be displayed only once—in this case, at the location of the server-side script:
psPage.ReportError(myLocation, myCause, "Incorrect password");
psPage.showErrorsOnPage = false;
The following example returns the value of the page variable myVar in an alert box the first time the page is accessed:
psPage.Alert (myVar + " in FirstTime event", true); return true;
InsertRow in the DataWindow Reference
Retrieve in the DataWindow Reference