You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Matt Hughes <mh...@chariotsolutions.com> on 2006/06/29 19:50:55 UTC
t:saveState and StateHolder
I am experiencing a bit of a problem with using t:saveState. Up until
now, I've always just made the bean that I was saving Serializable; but
today I came across a situation where I wanted more control over what
parts of the bean were actually saved.
My code follows. Basically, I have a backing bean with a field that
implements StateHolder. I try to saveState just that field:
<t:saveState value="#{backingBean.fooBar}" />
When FooBar just implemented Serializable, it got saved and restored
fine. When I changed FooBar to implement StateHolder, the
saveState/restoreState methods never got called. Am I missing something?
/** BACKING BEAN **/
public class BackingBean {
private FooBar fooBar;
public FooBar getFooBar()
{
return fooBar;
}
public void setFooBar(FooBar fooBar)
{
this.fooBar = fooBar;
}
}
class FooBar implements StateHolder
{
public Object saveState(FacesContext context)
{
System.out.println("Saving state");
return null;
}
public void restoreState(FacesContext context, Object state)
{
System.out.println("Restoring state");
}
public boolean isTransient()
{
return false;
}
public void setTransient(boolean newTransientValue)
{
}
}