Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

@ManagedBean Annotation JSF2  RSS feed

 
Abiodun Adisa
Ranch Hand
Posts: 495
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am from a Seam/JSF1 Environment. I configured my Bean using annotation but could not access the class from my JSP page
the class i defined is as follows

 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, part of your problem is that you don't access a class from a JSF View (what you called a "JSP"). You access an instance of a class.

Specifically, when you use the annotations that you illustrated, the JSF framework is going to instantiate a bean of class "Ab" and store it in your webapp's HttpSession object under the name "ab", since by default, the convention is to lower-case the class name's first character to form the instance name. That can be overridden with an annotation, but it's a reasonable naming convention.

So to refer to your bean's properties in a JSF view, you'd use the EL expression "#{ab.name}".
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!