• 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

Question on JSF Bean Property setting

 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys,

In Struts 2 we have our action classes implementing the ModelDriven and Preparable interfaces wherein the values for the bean property is set and we happen to see the values in the UI. Now what is the equivalent to this in JSF?
 
Saloon Keeper
Posts: 27763
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
JSF is almost pure MVC.

I sat almost, because pure MVC isn't possible for any web-based framework, since part of MVC is that if the model changes, the controller should post updates to the view, and HTTP isn't allowed to send unsolicited data. The next best thing is to send the view updates as part of a response to a subsequent request, and that's what JSF will do.

Unlike most desktop GUIs, JSF doesn't typically involve much controller coding, only Models and Views. For the most part, the controller is in the JSF tag implementations and in the JSF framework itself.

Backing Bean properties can be set either by having an action that references the bean do the setting (via invocation of the bean's mutator methods) or by the constructor process for Managed Beans. Unlike Struts Form Beans, JSF backing beans were intented to be pure POJOs. In real life, they often contain JSF model objects, so they're not strictly generic, but they're close. One common failing for newbies is stuffing JSF backing beans with a lot of javax.faces method and object references. That's actually not a very good practice. In many cases, it means they're not taking advantage of JSF's simplified mechanisms for achieving their goals. In many other cases, it's possible to excerpt the non-portable code to another place. Doing that makes it easier to reuse the bean in a non-JSF environment and to do unit testing on the bean outside the J2EE container framework.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic