Just wanted to let you all know that the changes to support stateless in JSF are going to be making it into the official JSF 2.2 specification and as such will be supported by all JSF implementations. Enjoy!
If you have wanted JSF not to store any state now is your chance to try out the stateless mode of JSF.
It is as easy as doing the following:
Your regular content
And voila you are running stateless.
If you decide you do want some state to be kept at the server you can use the
@xxxScoped annotations on your beans
Whenever the JSF runtime needs to perform a conversion it uses a Converter to do so. As explained in previous blog entries you have the ability to implement your own Converter. But does that mean you need to implement it for simple conversions? No, you do not, the default JSF converters come to the rescue!
The following blog articles are part of the JSF State Saving series
To facilitate component developers a convenience API was introduced to make it easier to implement the state saving requirements. Access to this API is made available through UIComponent.getStateHelper().
The API defines the following methods:
void add(Serializable key, Object value) Object eval(Serializable key) Object eval(Serializable key, Object defaultValue)
The definition of a PartialStateHolder according to the PartialStateHolder interface:
The definition of a StateHolder according to the StateHolder interface:
void restoreState(FacesContext context, Object state)
Object saveState(FacesContext context)
void setTransient(boolean newTransient)
Each of the methods mentioned above have a particular role to fulfill during the JSF lifecycle.
Since state saving happens as part of the JSF lifecycle a component, validator, converter, etcetera that wants to participate in state saving can do so by implementing or using one or all of the below mentioned APIs.
During the JSF lifecycle state will be restored at the beginning of a request (if any state is available) and state will be saved at the end of a request (if any state is available).
Why is it important to know what happens during request processing? Well, if you know how JSF state saving works you can optimize your application to perform better.
The following blog articles are part of the JSF Converter series