Datatable reRender not working with list re-ordering
kevhender Jan 23, 2009 11:51 AMI have a datatable that uses an EntityQuery.resultList to populate the data, where the list is ordered by a column called "sequence". The table has drag/drop capability, so that dragging the first cell of one row to the first cell of another moves that cell above/below the destination cell.
All of the drag/drop logic works, and the entities in the list are correctly modified. However, the reRender tag on the datatable does not change the order of the list -- it only changes the data.
So, I have a table that looks like this:
1 Row 1 2 Row 2 3 Row 3
When, for instance, cell 3 is dragged onto cell 1, the table gets re-rendered as:
2 Row 1 3 Row 2 1 Row 3
Obviously, the desired result would be:
1 Row 3 2 Row 1 3 Row 2
Via debugging, I see that the resultList DOES return the list in the correct order; however, the order is not changed on the screen, just the data for each row.
The table code:
<rich:dataTable
id="configurationList"
var="_item"
value="#{mainLookupList.resultList}"
rowKeyVar="rowKey">
<rich:column>
<f:facet name="header">
<h:outputLabel value="*"/>
</f:facet>
<a4j:outputPanel id="dropPanel">
<h:outputText value="#{_item.sequence}" />
<rich:dragSupport dragIndicator="indicator" dragType="item">
...
</rich:dragSupport>
<rich:dropSupport immediate="true" acceptedTypes="item"
reRender="configurationList"
dropListener="#{configBean.processDrop}">
...
</rich:dropSupport>
</a4j:outputPanel>
</rich:column>
<rich:column>
<f:facet name="header">
<h:outputLabel value="Name"/>
</f:facet>
<h:outputText value="#{_item.name}" />
</rich:column>
</rich:dataTable>
@Name("configBean")
public class ConfigBean extends EntityHome<MyType>
{
...
public void processDrop(DropEvent event)
{
//logic to re-order list, calling EntityHome.update() on each entity
this.mainLookupList.refresh();
}
...
}
@Name("mainLookupList")
public class ConfigurationList extends EntityQuery<MyType>
{
public ConfigurationList()
{
super();
super.setOrder("sequence");
}
@Override
public String getEjbql()
{
return ("select c from MyType c");
}
}
The configBean.processDrop is correctly changing the order of the list, and when I do a full page refresh after the drag/drop, the list is in the right order. Again, the problem happens with the reRender not changing the list order. Any ideas on why this is happening, and/or how to fix it? Thanks in advance.