How to reset JSF Portlets to initial state

For a JSF based portlet, if you have a scenario where a user is navigating between screens and that portlet is having 2 or 3 screens, if the user went to 3rd screen and he comes back and clicked on the link it is going to 3rd screen instead of 1st screen.

To render 1st jsp from within portlet,we specify init parameter for first jsp in portlet.xml as follows

<init-param>
    <name>com.ibm.faces.portlet.page.view</name>
    <value>/jsp/html/view/HelloView.jsp</value>
</init-param>


Now in case, when you want to reset JSF Portlets to its initial view when user comes back, set "com.ibm.faces.portlet.page.view" attributed to session.


portletSession.setAttribute("com.ibm.faces.portlet.page.view", <path of jsp to render>);

No comments: