• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

@ManagedBean Annotation JSF2

 
Ranch Hand
Posts: 495
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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}".
 
Destroy anything that stands in your way. Except this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic