2

What part of the JSF 2.0 framework handles the annotations? I really would like to add them to a JSF 1.2 application. Is that even a realistic goal?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Toby Samples
  • 2,168
  • 14
  • 15
  • Probably not. Why not migrate the new application to use JSF 2.0? The semantics of existing JSF 1.2 constructs shouldn't have changed much in 2.0. – millimoose Jan 27 '12 at 23:59
  • I am using Xpages from IBM which is stuff ontop of the JSF 1.2, so sadly not an option for me. – Toby Samples Jan 28 '12 at 00:11
  • You might consider Seam or Spring annotations as alternatives. There are versions of these that should work with JSF 1.2. – McDowell Jan 28 '12 at 11:34

1 Answers1

2

You can't use JSF 2.0 annotations in JSF 1.2 without basically upgrading the whole thing to JSF 2.0. You can however use CDI annotations (@Named, @Inject and likes) in JSF 1.2. As you're using old JSF 1.2, I'll assume that you're using an old Java EE 5 / Servlet 2.5 container. Although CDI is part of Java EE 6, you can use a standalone CDI implementation in a Java EE 5 / Servlet 2.5 compatible container. One of the CDI implementations is JBoss Weld. It's even officially supported on Tomcat 6.

CDI will cover the most what JSF 2.0 offers as managed bean annotations, including the three main scopes @RequestScoped, @SessionScoped and @ApplicationScoped. CDI does only not offer a fullworthy equivalent of the JSF 2.0 @ViewScoped annotation. Closest what it offers is the @ConversationScoped, but you'd need to manually start and end the injected Conversation.

CDI does not offer annotations which can replace @FacesConverter, @FacesValidator and likes, but that is likely not your major requirement.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555