Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API for "reset button" #1129

Closed
eclipse-faces-bot opened this issue Aug 3, 2012 · 8 comments
Closed

API for "reset button" #1129

eclipse-faces-bot opened this issue Aug 3, 2012 · 8 comments

Comments

@eclipse-faces-bot
Copy link

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:form>

<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>

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

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

" id="display" />

</h:form>

Bean;

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;

http://wiki.apache.org/myfaces/ClearInputComponents

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.

Regards.

Çağatay Çivici

Affected Versions

[1.1, 1.2, 2.0, 2.1, 2.0 Rev a, 2.1 Rev a]

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
Reported by @edburns

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
Issue-Links:
blocks
JAVASERVERFACES-2576
is duplicated by
JAVASERVERFACES_SPEC_PUBLIC-1060
is related to
JAVASERVERFACES_SPEC_PUBLIC-1060

@eclipse-faces-bot
Copy link
Author

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

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@edburns said:
Need verification from Cagatay.

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
Marked as fixed on Thursday, December 6th 2012, 12:46:02 pm

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@manfredriem said:
Closing resolved issue out

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
This issue was imported from java.net JIRA JAVASERVERFACES_SPEC_PUBLIC-1129

@eclipse-faces-bot
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant