Skip to main content

Why does @ViewScoped not work?

4 replies [Last post]
alan94539
Offline
Joined: 2005-09-06
Points: 0

I have a backing bean for a new user registration form, and I use to interact with the user. So this means the backing bean has to carry the state of what is currently selected until the user hits the go button.

So the bean is annotated @java.faces.bean.ViewScoped and @javax.enterprise.inject.Model.

For a few cycles of user interaction, the bean stays persistent, then for some reason it is discarded and a new one is instantiated, throwing all the state away. I can make the problem go away by going to SessionScoped, but that seems like a poor solution.

Do I misunderstand what @ViewScoped is supposed to do? I can't find any formal description other than "as long as the user stays on the view" the managed beans in the view scope are supposed to stay there. If this seems wrong, how do I go about trying to debug this?

Reply viewing options

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

There are some problems with @ViewScoped (which is a javax.faces bean)
and @Model (which is from javax.inject )

Try the Seam-Faces 3 Module, it should address some of these issues.
http://seamframework.org/Seam3/FacesModule

On Sat, Sep 18, 2010 at 5:48 PM, wrote:
> I have a backing bean for a new user registration form, and I use to interact with the user.  So this means the backing bean has to carry the state of what is currently selected until the user hits the go button.
>
> So the bean is annotated @java.faces.bean.ViewScoped and @javax.enterprise.inject.Model.
>
> For a few cycles of user interaction, the bean stays persistent, then for some reason it is discarded and a new one is instantiated, throwing all the state away.  I can make the problem go away by going to SessionScoped, but that seems like a poor solution.
>
> Do I misunderstand what @ViewScoped is supposed to do?  I can't find any formal description other than "as long as the user stays on the view" the managed beans in the view scope are supposed to stay there.  If this seems wrong, how do I go about trying to debug this?
> [Message sent by forum member 'alan94539']
>
> http://forums.java.net/jive/thread.jspa?messageID=483055
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>

--
Dominik Dorn
http://dominikdorn.com
http://twitter.com/domdorn

Tausche Deine Lernunterlagen auf http://www.studyguru.eu !

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

alan94539
Offline
Joined: 2005-09-06
Points: 0

> Try the Seam-Faces 3 Module, it should address some
> of these issues.
> http://seamframework.org/Seam3/FacesModule

I am not familiar with Seam. Does it work as a substitute for Mojarra or in addition to it?

Dominik Dorn

its just a jar you put into you webapps WEB-INF/lib folder, so you can
say its an addition.

On Sat, Sep 18, 2010 at 6:47 PM, wrote:
>> Try the Seam-Faces 3 Module, it should address some
>> of these issues.
>> http://seamframework.org/Seam3/FacesModule
>
> I am not familiar with Seam.  Does it work as a substitute for Mojarra or in addition to it?
> [Message sent by forum member 'alan94539']
>
> http://forums.java.net/jive/thread.jspa?messageID=483063
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>

--
Dominik Dorn
http://dominikdorn.com
http://twitter.com/domdorn

Tausche Deine Lernunterlagen auf http://www.studyguru.eu !

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

alan94539
Offline
Joined: 2005-09-06
Points: 0

OK, I'll check it out. Thanks.