wood burning stoves 2.0*
The moose likes JSF and the fly likes Loading DB data when web app context initialized Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Loading DB data when web app context initialized" Watch "Loading DB data when web app context initialized" New topic
Author

Loading DB data when web app context initialized

Bruce Riches
Greenhorn

Joined: Apr 24, 2006
Posts: 14
I've asked this question previously and I think that I phrased it badly.
So, here goes again.
This web app's welcome page contains a single <h:commandLink> that routes to a page upon which I need to display a list of db rows.
I retrieve the rows using a listener class defined in the web.xml file. I get the rows ok and I assign the rows (as a List object) to a managed bean - patientBackingBean - that has a property - patientList -that corresponds to the list.
However, when I use <h:dataTable in my jsp I see no results. The datatable tag looks like this-

><h:dataTable id="patlistid"
first="0"
rows="0"
value="#{patientBackingBean.patientList}"
var="patlist"
rowClasses="list-row-odd,list-row-even"
headerClass="table-header"
width="75%">

<h:column>
<f:facet name="header">
<hutputText value="Select"/>
</f:facet>
<h:selectBooleanCheckbox onclick="this.form.submit();" />
</h:column>

<h:column rendered="#{patient.patientId}">
<f:facet name="header">
<hutputText value="#{res[\'patient.patientid\']}"/>
</f:facet>
<hutputText value="#{patlist.patientId}"/>
</h:column>

and so on for each column.

I know that FacesContext is initialized at this point.
Any one have an answer?
TIA...
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Use an application scoped managed bean instead of the listener and inject it as managed property of the request scoped bean which you use in your table.
Bruce Riches
Greenhorn

Joined: Apr 24, 2006
Posts: 14
Actually, it turns out that that was what I was doing finally, just had made a mistake in implementing it.
Thanks anyway - at least I now know that that's the way to do this.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Loading DB data when web app context initialized
 
Similar Threads
How to use datatable with no records in a list
Input row select on data table does not get called
Help on JSF Custom tag
JSF datatable doubt
Unable to display header in outer JSF datatable of a nested datatable using facet tag