Java Virtal Machine.net

[ News ] rss

February 01, 2011

Mark Wielaard: New GPG key. Finally created a new GPG key using gnupg. The old one was a DSA/1024 bits one and 8 years old. The new one is a RSA/2048 bits one. I will use the new one in the future to sign any release tarballs I might create. pub 2048R/57816A6A 2011-01-29 Key f...

More »

February 01, 2011

Andrew Hughes: [SECURITY] IcedTea6 1.7.8, 1.8.5, 1.9.5 Released!. We are pleased to announce a new set of security releases, IcedTea6 1.7.8, IcedTea6 1.8.5 and IcedTea6 1.9.5. This update contains the following security updates: The IcedTea project provides a harness to build the source code from OpenJDK6 u...

More »

April/2024
SunMonTueWedThuFriSat
 123456
78910111213
141516171819 20
21222324252627
282930    

[ Archives News
for 'Java Technology' ]

home > news > java technology > is @javax.faces.bean.managedbean dead on arrival?

Is @javax.faces.bean.ManagedBean Dead on Arrival?

Java EE 6 has three different ways of defining “beans” that are “managed” in one way or another. Here is a quick recap. JSR 314 JSF 2.0 introduced annotations to avoid the tedium of declaring managed beans in faces-config.xml: @javax.faces.bean.ManagedBean(name="user") @javax.faces.bean.SessionScoped public class UserBean implements Serializable { ... } That's certainly nicer than user com.corejsf.UserBean session There is a second annotation for a rudimentary dependency injection mechanism: public class EditBean { @javax.faces.bean.ManagedProperty(value="#{user}") private UserBean currentUser; } When an EditBean instance is constructed, the value expression #{user} is evaluated, and the result is passed to the setCurrentUser method (which you must also supply) (It is a bit odd that the @ManagedProperty annotation is applied to a field when in fact the property setter is invoked. That is not how injection works elsewhere in Java EE. Let's not dwell on this oddity.) JSR 316 There is an annotation @javax.annotation.ManagedBean, defined by JSR 316, that attempts to generalize JSF managed beans for use elsewhere in Java EE. There isn't much there. You can use the @PostConstruct and @PreDestroy annotations. You can use @Resource for injecting EE resources. You can use interceptors. For example, if you define @javax.annotation.ManagedBean("user") public class UserBean ... ...


Date: December, 23 2009
Url: http://www.java.net/blog/cayhorstmann/archive/2009/12/23/javaxfacesbeanmanagedbean-dead-arrival


Others News

©2002-2019Java-Virtual-Machine.net https://mobirise.com/ | best web design software | free web design software | image slider | free bootstrap templates