• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Clearing Form on "success" outcome

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am new to JSF, I think I have a pretty simple question.

I have a form that posts back to itself, that adds a new user to a ldap tree, and everything works great except when the outcome from my action is "success" I want to clear out the form, and the backing bean. So the flow is that when the user submits a new user to be created if the outcome is "success" the same page gets loaded without the prepopulated form, if the outcome isn't success, then reload the page with all the form data present.

I can do this if I set <redirect /> but then any FacesMessage don't get displayed.

Here is my navigation rule:

<navigation-rule>
<from-view-id>/secure/main.jsp</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>
/secure/main.jsp
</to-view-id>
</navigation-case>
</navigation-rule>

Any help would be appreciated!

Thanks
 
Author
Posts: 134
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can clear it out in your submit method. Set values to empty strings or null in your submit method that is on the action for the commandButton
 
Chuck Syp
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jason thanks!

That seemed easy enough, for anyone else the has the issue, I used:

facesContext.getExternalContext().getRequestMap().remove("[your-managed-bean-name]");
 
Jason Porter
Author
Posts: 134
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Chuck Syp wrote:Jason thanks!

That seemed easy enough, for anyone else the has the issue, I used:

facesContext.getExternalContext().getRequestMap().remove("[your-managed-bean-name]");



That works. I was thinking more along the lines of this.someProperty = null, this.someProperty = "", but whatever works for ya
 
reply
    Bookmark Topic Watch Topic
  • New Topic