Search code examples
javajsfrichfacesseamjsf-1.2

How to maintain state of a request scope bean without using a4j:keepAlive in richfaces 3 and seam 2?


I have problem pertaining to the maintaining state of the particular @Request scope bean. I have a Seam Entity List request scope component. And after a particular request i want it to maintain its state and not to be refreshed, a4j:keepAlive do the solution but unfortunately using a4j:keepAlive destroy some other functionality inside a view so instead changing the whole page i just ignore a4j:keepAlive.

My question is, how can i maintain this particular scenario without using a4j:keepAlive and without making my component into @SessionScope or @ConversationScope.


Solution

  • If you're using JSF 2 for your website development, it would be better to use RichFaces 4. The RichFaces 3.3 is built to support JSF 1.2 mainly and then was extended to support JSF 2, still it doesn't take advantages of the benefits from JSF 2. RichFaces 4.x, in the other hand, is built thinking in JSF 2. It would be wise to move from RF 3.3 to RF 4, but if you still want to stick to RF 3.3, you should change the scope of your bean to ViewScope and stop using the a4j:keepAlive.

    More info:

    EDIT:

    For your given problem, you should save the data in session and recover it when your Request Managed Bean is created, doing that your data will be preserved through your view, but you have to do the job manually (very hard to maintain, also).

    If your managed bean has binding attributes with the jsp/facelet you're using, then don't use the a4j:keepAlive tag component, instead add the @KeepAlive(ajaxOnly=false) annotation to your request managed bean to save the entire state of your bean (even the binding components).