Using Ajax, this is quite sufficient to save and load data. In fact, the data will be saved even if the user navigates away somewhere else using the browser buttons or the browser address bar, or even just closes the browser. But this behavior is different from the traditional behaviors of forms with buttons called Reset and Submit. As such, this behavior may be unsettling to users who expect that nothing is saved anywhere until they click a nice solid-looking button.
The Reset button is useful in any case, as users may want to undo the changes they have made on the page.
To implement a RESET feature, do not use the INPUT TYPE=RESET, simply create a BUTTON
(can be outside FORM) or INPUT TYPE=BUTTON (has to be inside FORM) element,
label it "Reset",
and add a variable and handler for it on the Java side.
HtmlButton /* or HtmlInputButton */
resetButton = new HtmlButton( this, "reset" ) {
protected void onClick() {
resetFromSession();
}
};
That's enough, this will reset the items on the page from session, getting rid
of any changes the user has made.
This behavior can also be enabled in Jaxcent. To duplicate this behavior:
setFormSaveEnabled( false );
setFormSaveEnabled( true );
navigate( "/NewUrl.html" );
Before calling the setFormSaveEnabled and the
navigation, the button handler can also check
if any required form data is missing/wrong etc.
Exercise: Add Reset and Submit (for old-style submit) buttons to the http://localhost/Name.html page. This will require changing the XML map for Name.html, and adding a Java class.
| Next Step: Data Verification |