How to Persist Rows after Reordering in backing bean

UI Components for JSF
Post Reply
primesieger
Posts: 1
Joined: 07 Feb 2019, 12:30

12 Feb 2019, 16:01

I am using Primefaces Datatable to show the data, i have used draggablerows and trying to save/persist the reordering of the rows in the backing bean

with
<p:ajax event = onRowReorder listener=#{bean.onRowReorder}/>

I can get the from and to indexes from the event. But, I was not able to persist the row reordering:

<p:dataTable value="#{EmployeeHandler.model.employees}" var="employee" draggableRows="true">

<p:ajax event="rowReorder" listener="#{EmployeeHandler.onRowReorder}"/>

<p:column>
<h:outputText value="#{employee.id}"/
</p:column>
<p:column>
<h:outputText value="#{employee.firstName}"/
</p:column>

<p:column>
<h:outputText value="#{employee.lastName}"/
</p:column>
</p:dataTable>


I tried

public void onRowReorder(ReorderEvent event) {
event.getFromIndex();
event.getToIndex();
// I want to iterate through all the rows and save the new order of the employees list
}

kukeltje
Expert Member
Posts: 9377
Joined: 17 Jun 2010, 13:34
Location: Netherlands

14 Feb 2019, 17:33

Lots of discussion about this identical question here https://stackoverflow.com/questions/546 ... cking-bean, let's try to keep it in one place
Ronald van Kuijk
______________________________
PrimeFaces 6.1, PrimeFaces plus 0.0.2 | JbossWildfly 10.1| Mojarra 2.2.13
Fedora 61, Firefox 'most recent'
Read the forum posting rules
Beginners: https://jsf.zeef.com/bauke.scholtz

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Baidu [Spider] and 7 guests