Skip to main content

JSF 2.0: View scoped data should be Serializable?

3 replies [Last post]
martyhall
Offline
Joined: 2009-08-19

I put some non-Serializable data into view scope and got a warning from Glassfish. But, I went back and checked the spec (JSF_20090506.pdf) and couldn't find anywhere that said that it should be Serializable. In fact, I think there needs to be more detailed discussion of view scope in general.

I already make session data Serializable to support distributed sessions and because some servers store serializable session data on disk and reconstitute it when the server is restarted. But I would like some specific guidance in the spec as to why I ought to make view-scoped data Serializable as well.

View scope is a terrific idea, BTW. I suppose it is far too late to consider the possibility of that being the default scope, instead of request?

Cheers-

- Marty
http://www.coreservlets.com

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Ryan Lubke

On 9/9/09 2:02 PM, webtier@javadesktop.org wrote:
> I put some non-Serializable data into view scope and got a warning from Glassfish. But, I went back and checked the spec (JSF_20090506.pdf) and couldn't find anywhere that said that it should be Serializable. In fact, I think there needs to be more detailed discussion of view scope in general.
>
> I already make session data Serializable to support distributed sessions and because some servers store serializable session data on disk and reconstitute it when the server is restarted. But I would like some specific guidance in the spec as to why I ought to make view-scoped data Serializable as well.
>
ViewScope is attached to the UIViewRoot. When the UIViewRoot state is
saved, it may be serialized by the StateManager implementation.
Note that this may only occur if the save view is being redisplayed as
the spec requires the scope to be cleared when navigating to different
views.

> View scope is a terrific idea, BTW. I suppose it is far too late to consider the possibility of that being the default scope, instead of request?
>
> Cheers-
>
> - Marty
> http://www.coreservlets.com
> [Message sent by forum member 'martyhall' (hall@coreservlets.com)]
>
> http://forums.java.net/jive/thread.jspa?messageID=363442
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: webtier-help@glassfish.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: webtier-help@glassfish.dev.java.net

Ed Burns

>>>>> On Wed, 09 Sep 2009 14:22:43 -0700, Ryan Lubke said:

RL> On 9/9/09 2:02 PM, webtier@javadesktop.org wrote:

MH> I put some non-Serializable data into view scope and got a warning
MH> from Glassfish. But, I went back and checked the spec
MH> (JSF_20090506.pdf) and couldn't find anywhere that said that it
MH> should be Serializable. In fact, I think there needs to be more
MH> detailed discussion of view scope in general.

MH> I already make session data Serializable to support distributed
MH> sessions and because some servers store serializable session data on
MH> disk and reconstitute it when the server is restarted. But I would
MH> like some specific guidance in the spec as to why I ought to make
MH> view-scoped data Serializable as well.

Ok, I have added issue C032 to the ChangeLog [1]

[1] http://wiki.java.net/bin/view/Projects/Jsf2MR1ChangeLog

--
| ed.burns@sun.com | office: 408 884 9519 OR x31640
| homepage: | http://ridingthecrest.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: webtier-help@glassfish.dev.java.net

deepakpn
Offline
Joined: 2009-08-24

Are there any specific guidelines on when and how beans should be serialized?

From my understanding, it is recommended for session scoped beans to be serialized for reasons such as to support distributed sessions.

If the application isn't distributed, would session scoped beans still need to be serialized for other reasons?

For view scoped beans, the Errata C032 mentions that they "may" need to be serialized. Could you please elaborate on when/why about the scenarios in which serialization would be required so as to help us decide which beans to serialize in our application?

I am confused about how deserialization works. Would JSF lifecycle still take care of initializing the bean; would @PostConstruct annotations still work during deserialization or do we rely on other mechanisms for initialization after deserialization (e.g., no-arg constructor?)