Hi All, I have a problem now. My application has a sequence of 7 screens and at the end of 7th screen there is a Submit link which saves the values to database. I have the managed bean for all the pages in session scope so that the form retains the values even after the user navigates to say 6th page and comes back to first page. So now when the user submit the values finally I would like to clear the managed bean values in the session scope. Each managed bean has about 10 - 20 fields. Is there an efficient way to do this? Any input would be greatly appreciated. Thanks everyone for your time.
The link looks like what I wanted to do, but I could not get it to work. I even tried to get the values from session map by using FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("ManagedBeanClassName") Is that how we get an item from a session map?
You can have some resetting methods in each managed bean and call each one of them on click of Submit. You should be able to access one managed bean from another. I dont know if this is a good practice, but every property that I have in a managed bean, I also have it in the reset method of the managed bean. But do consider where the submit button should take to; will it still be showing the data present on these 7 pages? If this is the case you are better off calling those reset methods while navigating away from these 7 pages(like back to Main Menu or some other unrelated page). As an alternate, you could also call these reset methods at the time of starting the 7 pages workflow.
Note that above methods only reset the properties in the managed bean; the managed bean itself will still be in session. [ December 02, 2008: Message edited by: A. Dusi ]