Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Is it possible to access a bean variable in jsf?  RSS feed

 
prakash ke
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • 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?
 
Tim Holloway
Bartender
Posts: 18709
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • 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.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!