• Post Reply Bookmark Topic Watch Topic
  • New Topic

Clearing Form on "success" outcome  RSS feed

 
Chuck Syp
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • 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
 
Jason Porter
Author
Ranch Hand
Posts: 126
5
  • Mark post as helpful
  • send pies
  • 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
  • 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
Ranch Hand
Posts: 126
5
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!