first_page the funky knowledge base
personal notes from way, _way_ back and maybe today

JavaServer Faces in Action Notes: Chapter 2; JSF Fundamentals; 2.1.4 Backing beans

2.1.4 Backing beans

In the MVC world backing beans play the part of the controller, the interaction between the UI and the model. "Backing beans generally contain properties you want to retrieve from users and event listener methods... that process those properties and either manipulate the UI or perform some sort of application processing."

"You associate a component with a backing bean via the JSF expression language (EL), which is similar to the JSP 2.0 and JSTL expression languages." The expression for the rendered attribute in the <panelGrid> declaration below says, 'Do not render the component unless the backing bean counts more than 0 controls':

&lt;h:panelGrid
    rendered=&quot;#{helloBean.numControls &gt; 0}&quot;
    id=&quot;controlPanel&quot;
    binding=&quot;#{helloBean.controlPanel}&quot;
    columns=&quot;20&quot;
    border=&quot;1&quot;
    cellspacing=&quot;0&quot; /&gt;

"Here, the component's binding property uses a JSF EL expression to associate it with the HelloBean property controlPanel, which is of type HtmlPanelGrid." One difference between a backing bean and a "Model Object" is that the Model Object would not define types like HtmlPanelGrid. Model Objects should "know nothing" about the UI. It follows that, in our example above, you cannot use the binding property with Model Objects.

mod date: 2007-03-13T21:24:29.000Z