0

I have a multi page application form (jsf 1.2) with next and prev buttons for navigation. These pages should adhere the below requirements.

1) User should be allowed to move back and forth on those pages even with partially filled pages. The mandatory field validation should not stop him moving between screens.

2) Also the data he entered on a page should be restored back on his return to that page.

On an error case, jsf will postback to the same view always, but I solved this by using navigation handler inside a phase listeners after process validation callback.

But how could I save the current state before rendering the new page. I tried calling saveState on UIView before render phase, but that didn't work. How can I solve this?

What is the best way to address these requirements. I would very much appreciate an answer for this. Thanks.

Constraints : I have to address this in jsf 1.2, can't go for jsf 2.0 conversational state or third party solutions like tomahawk savestate :(

1 Answers1

0

If you just have to stick with JSF 1.2, then you can't. You have to save all the data you handle in the bean into the session, and recover everything in the bean constructor. If you can use a third party library, I'll recommend you RichFaces 3.3.3, it has a KeepAlive annotation that you can put on your request managed bean and turn it into a ViewBean (by saving the whole request bean in session and loading it if you're in the same view).

Example of KeepAlive annotation (as simple as it looks):

@KeepAlive
public class MyViewWannaBeBean {
    private String name;
    public MyViewWannaBeBean() {
    }
    //getters and setters...
}

Define the bean in the faces-config.xml like a request managed bean

<managed-bean>
    <managed-bean-name>myViewWannaBe</managed-bean-name>
    <managed-bean-class>mypackage.MyViewWannaBeBean</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
</managed-bean>
Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332
  • Thanks for your response luiggi. The problem is I need to save the state even if the process validation phase fails. In that case the flow wouldn't have reached update model phase and the backing beans wouldn't have been updated. I need to somehow store the component sate on the server in this case I believe. – user1457141 Jun 15 '12 at 05:56