Reset Form

Is there a simpler and faster way of resetting the form instead of creating a content provider, an action and then assigning empty values to all the input text boxes in action assignments?

Using Form.reset works as long as the form is not submitted to the server. After that, the function resets the form to the values what was submitted to the server.

My problem is: I can create a content provider, add an action and then assign empty values only to the input text boxes. I cannot assign empty values (in the action) to the table columns (and remove rows that the user creates using Add Row button) that I created for input document list.

All I want is to reset the form as it’s loaded the first time when the page loads.

If we can assume that the managed beans involved in drawing your page are all configured to expire with the page flow scope (which is the default behavior), then calling the resetPageFlowStorage() API from your page bean would dump all of those existing managed beans and start over.

For example:

    * Action handler that resets the managed beans in the page flow storage
   public String reset() {
        return null;

I used this code on a custom script raised on on-click event of “Reset” button. It reset the form if the form has not been submitted to the server. After it has been submitted to the server, then clicking the “Reset” button changes the values of the fields to the one submitted to the server.

For example: AddressLine1 is empty on page load, user enters 123 Main St. and clicks “Save” on which the form is submitted to the server. If we click on reset before Save, then it makes addressLine1 empty. After Save, if we change addressLine1 to 1st street, then resetPageFlowStorage() make the field value back to 123 Main St. (the one submitted to the server) instead on empty value. Please see attached sample project. (13.1 KB)

The snippet I suggested before was java code, so it would need to go in your page bean java class.

I have repaired your sample to make it work and attached it here for your reference.

I removed your custom script control (and extra disjoint form) and updated the ‘Reset’ button configuration as below:
a) cleared the ‘Forms’ property so it would just submit the main form instead
b) set the ‘Action’ property to the resetPage method that I added to your page bean
c) set the ‘Immediate’ property to “true” so it will now invoke the action without doing any validation of your form fields when you submit the form. (13.2 KB)

Awesome. Thank you.