0

Im having a question regarding retrieving the view state of a JSF page. I have an application in which the user is able to search for persons in a list and when the user press "show" button the same JSF page will be filled with a list of the various persons. Now when I choose one of the persons , another JSF page will show up with more in-depth and detailed information about that person. Now in that page there is a "cancel/abort" button displayed. What I want to accomplish is that when I press that specific "cancel/abort" button the page should be redirected and navigate back to the JSF page with the list as it was shown, so in some way the "view state" should be stored (I assume only) but I dont know how it could be done... I just wanted to check if anyone has been able to solve this kind of issue in some manner.. ? (The JSF search page as mentioned above is declared as a viewscoped as an additional information)

Thanks for all help..

Erfan
  • 113
  • 1
  • 3
  • 7

1 Answers1

0

You could make the bean @SessionScoped. That means that only one instance will be created by browser session, so when you get back you get the last state. Of course, session scoped means that when you get back to the view even if it is not a "back" navigation, that info will still be there.

SJuan76
  • 24,532
  • 6
  • 47
  • 87
  • The problem is that in the project its one of the requirements that the members should only write programs which are "viewscoped", otherwise I know there are alternative ways of declaring beans.. – Erfan Nov 06 '12 at 13:04
  • You have to persist the view state somewhere. You can try to "cheat" and store a bean directly in the session map and retrieve it, you can store it in database or in a file (or a cookie). But you can not do it directly with a view scoped bean, that is for sure. – SJuan76 Nov 06 '12 at 14:42
  • Do you have any examples of how that can be accomplished? – Erfan Nov 06 '12 at 14:45