Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Loading DB data when web app context initialized

 
Bruce Riches
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic