0

About saving the state of JSF application on a temporary basis, without using session:

An alternative is using t:saveState of Apache Tomahawk library; another more recent alternative is using CDI @ConversationScope.

t:saveState x @ConversationScope
What is the advantages and pitfalls of each one? Which one would you use and why?
About memory consuption (space and time consumed on session) , is @ConversationScope anyhow better?

Stateless JSF x t:saveState
On JSF 2.2 there will be the possibility of running stateless. Since the component tree isn't persisted anymore, t:saveState won't work. Is it correct?!

I have a app that is migrating from JSF 1.2 to JSF 2.x. It has a lot of views using t:saveStave.
Currently the session size is getting too large. This is a problem mainly with session replication.

Does it worth replacing t:saveState to @ConversationScope?


Update: Most of out use cases are flow (like wizard). Thus, @ViewScope couldn't be applied.

RicardoS
  • 2,088
  • 1
  • 21
  • 22

1 Answers1

4

About saving the state of JSF application on a temporary basis, without using session:

An alternative is using t:saveState of Apache Tomahawk library; another more recent alternative is using CDI @ConversationScope

<t:saveState> is from old JSF 1.x times and its use should remain for those applications. @ConversationScope comes from CDI 1.0, to extend the life of the state of JSF beans and components along several requests, and uses an identifer that pass along the requests.

The best alternative when using JSF 2 is @javax.faces.bean.ViewScoped, and since JSF 2.2 you should use @javax.faces.view.ViewScoped which is compatible with CDI 1.1.

If you're going to use JSF 2.0.x or 2.1.x along with CDI 1.0, then you won't be able to use @ViewScoped. To solve this, there are third party libraries that allows view scope for your JSF beans managed by CDI.

Does it worth replacing t:saveState to @ConversationScope?

Since you're migrating to JSF 2.x, you must drop usage of <t:saveState> at all. Depending on the JSF 2.x version, you should use @ViewScope or its alternative. I would not recommend using @ConversationScope unless you want/need to keep the beans alive through several views like when implementing a flow, but JSF 2.2 also solves this by using @FlowScoped.

More info:

Community
  • 1
  • 1
Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332
  • Hi. It's still possible to use t:saveState on JSF 2, but nevertheless of that it's better drop it, right?! Sorry, I haven't said it before, but our use case really is a wizard (or flow). In this case would be ok to use ConversationScope?! – RicardoS May 19 '14 at 13:08
  • And do you know anything about it's memory consuption? Thanks in advance. – RicardoS May 19 '14 at 13:09
  • 1
    @RicardoSilva if you're using JSF 2.2 use `@FlowScoped` it is suited for wizards. If you're stick to JSF 2.0 or 2.1, use `@ConversationScoped`. – Luiggi Mendoza May 27 '14 at 19:12