| Author |
Datatable trying to access non-existent field from Bean
|
Ayan Afridi
Greenhorn
Joined: Jan 18, 2005
Posts: 24
|
|
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 utputText value="UM02" /> </h:commandLink> <h:commandLink action="UM03"> <h utputText 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 utputText value="Back Home"></h utputText> </h:commandLink> </hx:panelBox> </f:facet> </h:dataTable> </h:form> {code}
|
 |
 |
|
|
subject: Datatable trying to access non-existent field from Bean
|
|
|