• 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
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Datatable trying to access non-existent field from Bean

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am having a very strange problem in JSF. I currently have one links page with four commandLinks in it, and one JSF page witha datatable in it, and an IBM <hx:pagerDeluxe> in it to page through the data. Each command link fires off a different action, as shown below:

{code}<h:commandLink action="UM02">
<h:outputText value="UM02" />
</h:commandLink>
<h:commandLink action="UM03">
<h:outputText value="UM03" />
</h:commandLink>{code}
..........etc ........

My Navigation rules all point to one JSP file, but with a different param appended to the URL:
{code}
<from-view-id>/index.jsp</from-view-id>
<navigation-case>
<from-outcome>UM02</from-outcome>
<to-view-id>/jsp/mappings/listViewUM02.jsp?tbl=UPD_MAP_UM02</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>UM03</from-outcome>
<to-view-id>/jsp/mappings/listViewUM02.jsp?tbl=UPD_MAP_UM03</to-view-id>
</navigation-case>{code}

So as you can see, I have one JSF file to display a list from any given table name. I also dynamically populate the dataTable through my code, by reading through a list of columns for each table, and creating a "UIColumn":

{code}while( itr.hasNext() ){

String fieldName = (String) itr.next();
ValueBinding vb = FacesContext.getCurrentInstance().getApplication().createValueBinding("#{var." + fieldName + "}");
HtmlOutputText header = new HtmlOutputText();
header.setValue(fieldName);
UIColumn col = new UIColumn();
UIOutput out = new UIOutput();
out.setValueBinding("value", vb);
col.setHeader( header );
col.getChildren().add(out);
dataTable.getChildren().add(col);
}{code}

And that dataTable is shown in the JSF page. So i can go back to the main links page, click on another table name, and it will populate the datatable with the correct columns, data, etc. The problem happens when I go to one table, say UM02, and hit ">" on the pager, to go to the next page, which works, THEN i go back to the links page, and hit "UM03" and the first page displays fine. When I try to go to the next page, I get an error saying that the backing bean UM03Bean does not have field "subProductCd". Basically, values from the old dataTable objects are being used for smoe reason when I page. Not sure why this is happening.

My datatable is defined like this:

{code}<h:form id="dataTableForm"><h:dataTable id="dataTable1" border="0" cellpadding="2"
cellspacing="0" columnClasses="columnClass1"
headerClass="headerClass" footerClass="footerClass"
rowClasses="rowClass1, rowClass2, rowClass3"
styleClass="dataTableEx" width="70%" rows="10"
value="#{TestAction.list}" var="var"
binding="#{TestAction.listDataTableUI}">

<f:facet name="footer">
<hx:panelBox styleClass="panelBox" id="pagerbox">
<hx:pagerDeluxe styleClass="pagerDeluxe" id="deluxe1" for="dataTable1"/>
<h:commandLink action="home">
<h:outputText value="Back Home"></h:outputText>
</h:commandLink>
</hx:panelBox>

</f:facet>
</h:dataTable>
</h:form>
{code}
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic