[JAVASERVERFACES_SPEC_PUBLIC-1129] API for "reset button" Created: 03/Aug/12  Updated: 01/Aug/14  Resolved: 06/Dec/12

Status: Closed
Project: javaserverfaces-spec-public
Component/s: Lifecycle
Affects Version/s: 1.1, 1.2, 2.0, 2.1, 2.0 Rev a, 2.1 Rev a
Fix Version/s: 2.2 Sprint 14

Type: Bug Priority: Minor
Reporter: Ed Burns Assignee: Ed Burns
Resolution: Fixed Votes: 1
Labels: None
Remaining Estimate: 23 hours, 17 minutes
Time Spent: 6 hours, 43 minutes
Original Estimate: 1 day, 6 hours

Issue Links:
blocks JAVASERVERFACES-2576 Implement ResetInput Closed
is duplicated by JAVASERVERFACES_SPEC_PUBLIC-1060 Reset EditableValueHolders which are ... Closed
is related to JAVASERVERFACES_SPEC_PUBLIC-1060 Reset EditableValueHolders which are ... Closed


I'd like to discuss something I've been thinking about lately. How to clear forms easily when validation fails?

Consider this simple case;


<h:messages />

<h:inputText value="#

{pprBean.firstname}" required="true"/>
<h:inputText value="#{pprBean.surname}" required="true"/>

<h:commandButton value="Save">
<f:ajax render="@form" execute="@form"/>

<h:commandButton value="Reset" actionListener="#{pprBean.reset}">
<f:ajax render="@form" execute="@this"/>

<h:outputText value="#{pprBean.firstname}

" id="display" />



private String firstname, surname;

public void reset()

{ firstname = null; surname = null; }

So when you run this, if one of the field is empty and the other is not, validations fails and message is displayed. Problem happens when reset button is clicked to reset the form values. At processValidations phase UIInput saves the converted value at state
and since validation failed, update model is not executed so local value is never cleared. Clicking reset, clears the bean's values but inputText will not use the bound value and use the one kept in state as well ending up a confusing behavior. I've seen this in many forums.

I know wiki's like this;


But I mean shouldn't this work as expected? Proposed solutions seem way too hard just to clear form values. (component binding and calling resetValue(), new view, javascript etc.)

If at processValidations phase, local value is not stored in state, I think that will make the code above work, but I'm not sure if there will be any side effects. Does anyone know why converted local value is kept at state by calling setValue(). Both mojarra and myfaces keeps the value at state and I cannot find anything regarding this in spec, please point me if I'm wrong.


Çağatay Çivici

Comment by Ed Burns [ 05/Dec/12 ]

When sitting down to implement this, I discovered at least one additional aspect that must be specified. AjaxBehavior must have a boolean "resetInput" property.

Comment by Ed Burns [ 06/Dec/12 ]

Need verification from Cagatay.

Comment by Manfred Riem [ 01/Aug/14 ]

Closing resolved issue out

Generated at Mon Dec 05 04:10:44 UTC 2016 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.