Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Clear form

 
Mahendra Pratap
Ranch Hand
Posts: 42
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am facing a problem while clearing jsf form..


actually the scenario is i am having a jsf form with 7-8 components each component have some validator associated with it.. so for clear button i have provided immediate = true attribute to bypass the validations

but as there is immediate attribute associate with clear button while loading the page on client side it is bypassing Update model values

i am unable to figure out a solution to this situation can any of you give needful inputs.

Thanks,
 
Tim Holloway
Bartender
Posts: 18423
60
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A fundamental architectural feature of JSF is that no model (backing bean) can be updated without first passing the validators. "immediate=true" bypasses the updates, and thus bypasses the validators. Not specifying "immediate=true" will update, but only if all the data validates.

The only ways around that are to adjust your validation requirements or to break the view into a set of forms such that the operation doesn't attempt to update the invalid items.
 
Mahendra Pratap
Ranch Hand
Posts: 42
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim for your quick response.

yeah i am agree with your point..

But the problem is on clear button the backing bean action method is getting called and i checked there about the current value of fields they are not yet updates means still having the default value, but as the page reloads the value which i entered earlier are not getting reset.

In other way round those fields are not getting rendered, why? any clue?


Regards,
 
Tim Holloway
Bartender
Posts: 18423
60
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't understand that. Are you just trying to return to the original values that were displayed when the page was presented?

If that's what you want, use a button type of "Reset". It will cause the browser to restore those values, not send anything at all to the server, and thus leave the backing bean with its values unchanged from when you presented that page.
 
Mahendra Pratap
Ranch Hand
Posts: 42
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah i just want to restore to the previous values..

you got me right..

this is code for reset button i tried this but not failed to restore values..

 
Higgledy Smith
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great thread! Thank you.
 
She still doesn't approve of my superhero lifestyle. Or this shameless plug:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!