users@glassfish.java.net

Re: _at_Model versus _at_Named versus _at_ManagedBean

From: Dominik Dorn <dominik.dorn_at_gmail.com>
Date: Sat, 11 Sep 2010 12:50:13 +0200

afaik, @Model is just a wrapper for (javax.inject.)@Named
@RequestScoped @ManagedBean (->
http://javadoc.glassfish.org/javaee6/apidoc/javax/enterprise/inject/Model.html
)

The community tends to stay away from the JSF @ManagedBean and
@Request/Session/ApplicationScoped and uses the appropriate one from
javax.inject.

One thing where they still stick to jsf's annotations is @ViewScoped as its
still kind a hack to use that one with CDI but I think its working
with the current
Seam Faces beta build.


On Sat, Sep 11, 2010 at 5:19 AM, <glassfish_at_javadesktop.org> wrote:
> I am working up my first JSF 2.0 application under GF 3 and ran into this issue that is bugging me.  There does not seem to be any definitive answer I can find on this and I want to follow best practices start to finish.
>
> By experimentation and reading examples on the web I have found that I can create managed beans for my application by either using the annotations @java.faces.bean.ManagedBean, or by @javax.inject.Named, or by @javax.enterprise.inject.Model.
>
> The JSF 2.0 books say to use @ManagedBean.  The NetBeans template uses @Named.  And then when I look into the CDI specification their JSF example uses @Model.
>
> The same applies to using the bean, either @javax.inject.Inject, or JSF's @Resource.
>
> Don't get me wrong I am happy they all seem to work.  But what is the RIGHT one to use, i.e. "best practice?"   For that matter what is the difference?
> [Message sent by forum member 'alan94539']
>
> http://forums.java.net/jive/thread.jspa?messageID=482397
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>



-- 
Dominik Dorn
http://dominikdorn.com
http://twitter.com/domdorn
Tausche Deine Lernunterlagen auf http://www.studyguru.eu !