How to use JavaScript to verify a user request on the client (browser) before sending it to the server.
You can run this technique code from:
NOTE First make sure that database is running on your localhost SilverStream Server | |
See the chapter on advanced page topics in the Programmer's Guide |
The following describes how to add JavaScript code to a page.
The following code shows the JavaScript that launches a dialog box upon the Button1 button click.
method handle_Button1_onClick() { if (confirm("Are you sure you want to execute this code?")) { Page.submit(this.Button1.name); } }
confirm()
and supplying the message string as the parameter. confirm()
is a method of the Window
object. This method returns true if the user selects OK; it returns false if the user selects Cancel.
pageActionPerformed
event should be fired. This line of code specifies that Button1 is the object whose pageActionPerformed
event will be fired.
The following code runs when a Submit request is processed by the server. This request was sent by the JavaScript when the user clicked the OK button in the Confirm dialog box.
private void handle_Button1_pageActionPerformed(ActionEvent evt) throws Exception { Hashtable message = new Hashtable(); message.put("MESSAGE", "You answered OK after you clicked Button1."); message.put("URL1", "SilverStream/pages/pgConditionalSubmit.html"); message.put("LINK1", "Return to pgConditionalSubmit.html"); showPage("../../message.html", null, null, message); }
Hashtable
and provide the parameters for use by the message page.