Spent 2 days to figure what went wrong with my t:datatable not displaying the updated list after submitting an action. It keeps on displaying old data (data before any action was performed).
My jsp:
<t:dataTable
preserveDataModel=”false”
preserveRowStates=”false”
binding=”#{oit.dataTable}”
value=”#{oit.tasksInError}”
var=”tie”
styleClass = “resultTable”
cellspacing=”1″ cellpadding=”0″
id=”tieTable”
renderedIfEmpty=”false”><t:column headerstyleClass=”resultTableHeader”
styleClass = “resultTablePurpleLight textLeft” ><h:selectBooleanCheckbox immediate=”true”
rendered=”#{tie.displayCheckbox}”
id=”selectError”
value=”#{tie.checkBoxSelected}”/><h:inputHidden id=”errorId” value=”#{tie.errorID}”/>
<f:facet name=”header”>
<h:outputText value=”#{msgs.select}”/>
</f:facet></t:column>
</t:dataTable>
After banging my head really hard on the wall (yeah right..), I managed to isolate the bug. It only happens when the list only contain one single item. And after googling around, I found a quick temporary solution!! Hooraaaah~~ I still don’t understand this bug. But the fixed shown in the mailing list is sufficient for now.
The magic part is the 2 lines shown in bold below. Whenever you iterate through a datatable, you need to set row index back to its original value.
My backing bean:
public void errorAction(String action) {
/* Save the current row index. */
int currentRowIndex = dataTable.getRowIndex();for (int i = 0; i < dataTable.getRowCount(); i++) { dataTable.setRowIndex(i); ... } /* Restore the row index. */ dataTable.setRowIndex(currentRowIndex); }
Note: This application is using Tomahawk 1.1.6, JSF 1.1, running on Sun Application server 8.2.