I have a rich:dataTable component (RF 4.2.2.Final). I've added the rowclick listener for the table to update a detailed view based on the row selection. Everything was working fine. But now I'm trying to get my dataTable to have sortable headers. I follow the RF showcase and find out that the row selection doesn't work properly if the data in the dataTable isn't in natural order - it means in order in which the data is in the list in appQueryBean. But I'm sure that similar case is fine in RF 3.X
My page:
<h:form id="appFormId">
<div>
<rich:dataTable id="appListTableId" value="#{appQuery.applicationList}"
var="row" rendered="#{!empty appQuery.applicationList}"
rows="50" styleClass="styledTable">
<a:ajax
listener="#{appQuery.actionListener(row.id)}"
event="rowclick" render=":applistform:appViewId"/>
<rich:column style="width:10%">
<f:facet name="header">#{msg['ID']}</f:facet>
<h:outputText value="#{row.id}" />
</rich:column>
<rich:column style="width:20%" sortBy="#{row.code}"
sortOrder="#{applicationSortManager.sortOrder}">
<f:facet name="header">
<a:commandLink
value="#{msg['APPLICATION.CODE']}" render="appListTableId"
action="#{applicationSortManager.sortByCode}" /></f:facet>
<h:outputText value="#{row.code}" />
</rich:column>
<rich:column style="width:50%">
<f:facet name="header">#{msg['APPLICATION.NAME']}</f:facet>
<h:outputText value="#{row.name}" />
</rich:column>
<f:facet name="footer">
<rich:dataScroller id="appBottomScroller" for="appListTableId"
renderIfSinglePage="false" immediate="true" align="left"/>
</f:facet>
</rich:dataTable>
<div>
</h:form>
And ApplicationSortManager:
@Named
@SessionScoped
public class ApplicationSortManager implements Serializable{
private SortOrder sortOrder = SortOrder.unsorted;
public void sortByCode(){
if (sortOrder.equals(SortOrder.ascending)) {
setSortOrder(SortOrder.descending);
} else {
setSortOrder(SortOrder.ascending);
}
}
/**
* @return the sortOrder
*/
public SortOrder getSortOrder() {
return sortOrder;
}
/**
* @param _sortOrder the sortOrder to set
*/
public void setSortOrder(SortOrder _sortOrder) {
sortOrder = _sortOrder;
}
}
AppQuery is a ViewScoped component with test actionListener implementation:
public void actionListener(Long _idApplication){
System.out.println("Action listener - appId: " + _idApplication);
}
No matter what is the real order in dataTable - when I click in first row I always get the appId: 1, when second - appId: 2.
How to get the data from row I clicked if the dataTable is sorted?