Online Books:
java.net on MarkMail:
Search |
||||
TOTD #49: Converting a JSF 1.2 application to JSF 2.0 - @ManagedBeanPosted by arungupta on October 17, 2008 at 9:52 AM PDT
This is a follow up to TOTD #48 which showed how to convert a JSF 1.2 application to use new features of JSF 2.0. In this blog, we'll talk about a new annotation added to the JSF 2.0 specification - @ManagedBean. @ManagedBean is a new annotation in the JSF 2.0 specification. The javadocs (bundled with the nightly) clearly defines the purpose of this annotation: The presence of this annotation on a class automatically registers the class with the runtime as a managed bean class. Classes must be scanned for the presence of this annotation at application startup, before any requests have been serviced. Essentially this is an alternative to <managed-bean> fragment in "faces-config.xml". This annotation injects a class in the runtime as a managed bean and then can be used accordingly. Using this annotation, the following "faces-config.xml" fragment from our application:
is simplified to
and
The specification defines that managed bean declaration in "faces-config.xml" overrides the annotation. Section 11.5.1 of JSF 2.0 EDR2 specification defines several similar annotations that can be used to simplify "faces-config.xml". Have you tried your JSF 1.2 app on Mojarra 2.0 ? Drop a comment on this blog if you have. File JSF related bugs here using "2.0.0 EDR1" version and ask your questions on webtier@glassfish.dev.java.net. Please leave suggestions on other TOTD (Tip Of The Day) that you'd like to see. An archive of all the tips is available here. Technorati: totd javaserverfaces glassfish mojarra netbeans »
Related Topics >>
Glassfish Comments
Comments are listed in date ascending order (oldest first)
Submitted by agoncal on Sat, 2008-11-01 04:40.
Arun, thanks for the tip. Now that we know a little bit more about how to use @ManagedBean and @ManagedProperty, how will we do navigation with JSF 2.0 ? I read that faces-config.xml will be optional. That means that navigation could also be done using annotations. Any tip about that feature ?
|
||||
|
|