You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by CarlHowarth <ca...@dlapiper.com> on 2006/10/06 13:02:34 UTC

Hi,

I have an app that uses the tomahawk savestate component to save the state
of the backing bean. I have just tried bind a selectonemenu component to the
backing bean however as the HtmlSelectOneMenu class is not serializable I
get an error as this can not be saved.

If I change to session scope, removing the savestate component the app
works, however I do not want the bean to be stored at session level. Has
anyone had this problem/got a work-around?

Many thanks, Carl
-- 
View this message in context: http://www.nabble.com/%3Ct%3Asavestate..-component-binding-serializable-problem-tf2394756.html#a6677044
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: Posted by Kevin Galligan <kg...@gmail.com>.
You could do the following:

1) Mark the bound reference 'transient'.  It won't be serialized.

2) Manually implement the Serialize methods.

3) Implement the 'StateHolder' interface, which is similar to #2,
except closely tied to JSF/Myfaces.  For this to work, you need a
recent tomcat source build as it was fixed not too long ago.

4) Change your design to not run 'saveState' on the whole bean (I have
no idea how your app is designed, so might not be viable).

Personally I'm going to start using #3 when needed, but my app is set
up to deal with mostly singular id values, so I generally use
'saveState' on just those values specifically rather than the whole
bean, and so I tend to avoid these issues.

Friends don't let friends use the session to store request level data.

On 10/6/06, CarlHowarth <ca...@dlapiper.com> wrote:
>
> Hi,
>
> I have an app that uses the tomahawk savestate component to save the state
> of the backing bean. I have just tried bind a selectonemenu component to the
> backing bean however as the HtmlSelectOneMenu class is not serializable I
> get an error as this can not be saved.
>
> If I change to session scope, removing the savestate component the app
> works, however I do not want the bean to be stored at session level. Has
> anyone had this problem/got a work-around?
>
> Many thanks, Carl
> --
> View this message in context: http://www.nabble.com/%3Ct%3Asavestate..-component-binding-serializable-problem-tf2394756.html#a6677044
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>

Re: Posted by Werner Punz <we...@gmx.at>.
CarlHowarth schrieb:
> Hi,
> 
> I have an app that uses the tomahawk savestate component to save the state
> of the backing bean. I have just tried bind a selectonemenu component to the
> backing bean however as the HtmlSelectOneMenu class is not serializable I
> get an error as this can not be saved.
> 
> If I change to session scope, removing the savestate component the app
> works, however I do not want the bean to be stored at session level. Has
> anyone had this problem/got a work-around?
> 
Savestating is not used for components, sorry to say that, and the classes
used by this component have to be serializable due to the inherent
nature of the mechanisms used.
Your backing bean however is, and you have to use a Serializable on the
backing bean to use savestate.

Btw. just another note, saveState in the long run will be replaced by
something better, we have a scope component in the sandbox, which is
very similar in usage, but way better.

I have not used it myself, but the developer of this component uses it
heavily so it is pretty well debugged.
The benefits of this component, clear begin and end scope definition,
some generic bindings into orm layers so that you have an easier
handling with orm layers.

Savestate is, though very easy to use, somewhat limited.