• 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

"Prerender" functionality in UI:Composition

 
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 have an application where i need to load the UI:Composition when clicked.

i have a requiremnt that i need to load the data from the database everytime i render the UI:Composition
I have tried doing
<f:event type="preRenderView" listener="#{list.loadListDetails}"/>
but it doesnt work in the UI:Composition

please help me find a way to

Call a Backing Bean Method when UI:Composition is loaded

thanks in advance
 
Saloon Keeper
Posts: 27807
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
I may not be able to explain this well, but "you" do not render. Rendering is done as the last stage (render response) of the JSF lifecycle and control of the rendering process is done primarily by the JSF Controller (FacesServlet) which takes the compiled View templates and produces the response data stream by merging the View with the Models (backing beans).

So you should be able to load the database data into a Model using the action method that resulted in the production of the View. The normal processes of the JSF lifecycle will take care of the rest.

In the case where no action was fired (a URL was submitted for initial page display), you need to find an alternative way to populate the Model.

As it happens, there's a single solution for both scenarios. What I do is null out my sub-model object (which is typically a DataModel wrapping the actual database data). Then, when JSF does its initial "get" on the submodel property, I do the fetch, construct the sub-model property and cache it. This is important, because otherwise the data might get loaded 5-6 times in a single page request and response time would be atrocious.

Thus, at any time, for any reason, I can refresh the data view by simply nulling out the sub-model again.
reply
    Bookmark Topic Watch Topic
  • New Topic