• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Is it possible to access a bean variable in jsf?

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I want to access a string variable from a managed bean and compare it another value and thereby render a table only if they are equal.


Can anyone help me on this?
 
Saloon Keeper
Posts: 28753
211
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
JSF is all about accessing bean variables, as long as they are presented as JavaBean properties.

There are several ways to do this. One is by brute-force EL:


Another way is to present the rendering logic as a property itself:




This is recommended for more complex logic and/or where you want to reduce the coupling between Model and View. Which also is more in the spirit of MVC, as it puts the logic in code instead of in the View definition. Actually, the UI controlling code is technically part of the Controller feature, but JSF's controller features are a bit different than the traditional arrangement.

Note that JSF's injection feature means that the "showMe" property on ctlBean can be injected as a Managed Property from some other managed bean.
reply
    Bookmark Topic Watch Topic
  • New Topic