In Windows applications, message boxes are used to handle the display of information and process confirmations. With a WebApp this is more complicated because a confirmation requires client-server round trip requests and responses. The WebApp framework provides a standard method for handling this.
The ShowInfoBox message is used to display a message and title caption.
Send ShowInfoBox "Testing 1 2 3" "Test"
The ShowYesNo message is used to handle yes/no confirmations. It uses the lower level ShowMessageBox, which can also be used to process other types of custom confirmations.
Both ShowYesNo and ShowMessageBox use the concept of a callback object and message. These are passed to the procedure and passed to the client. Upon completion, the client makes a server call, which will send a callback message to the callback object passing the results of the confirmation. Therefore, a confirmation must consist of code for creating the confirmation and a method handler to handle the response.
The following is an example where a client button click will call OnClick, which then performs a yes/no confirmation. This confirmation triggers a call to the ButtonCallback method that receives the response to the yes/no confirmation.
Object oChangeButton is a cWebButton
Set psCaption to "Click me"
Procedure ButtonCallback Integer eConfirmMode
If (eConfirmMode=cmYes) Begin
WebSet psCaption to (CurrentDateTime())
// this tells the system that this method is allowed for this object
// do confirmation and call this object's ButtonCallback message with the results
Send ShowYesNo (Self) (RefProc(ButtonCallback)) "Update this" "Question"
When callbacks are used, the callback must be an allowable callback for the callback object. This is accomplished by publishing the method, which is what the WebPublishProcedure command does here. This is done to make sure that only known methods are processed on the server.
Note that this confirmation is already built into the data entry framework and save (Verify_Save_Msg), delete (Verify_Delete_Msg) and data-loss (Verify_Data_Loss_Msg) confirmations are set to an appropriate confirmation method. By default, those confirmations are enabled and they call the built in SaveConfirmation, DeleteConfirmation and DataLossConfirmation methods.
Previous Topic: Creating and Maintaining a Web Application
Next Topic: Web Properties
Developing Web Applications