Reputation: 1362
I have a little problem with PrimeFaces, I am trying to add an event listener to colReorder event but when I add this the whole stuff fails with Uncaught SyntaxError: Unexpected token.
The code looks like this:
<p:dataTable
width="100%"
value="#{myBean.getItems()}"
var="item"
id="resultList"
draggableColumns="true"
>
<p:ajax event="colReorder" listener="#{myController.onColumnReorder}" />
...
And the backing bean:
@Named
@RequestScoped
public class MyController implements Serializable{
public void onColumReorder(ReorderEvent event) {
FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Row Moved", "From: " + event.getFromIndex() + ", To:" + event.getToIndex());
FacesContext.getCurrentInstance().addMessage(null, msg);
}
}
The strange is that if I remove the p:ajax everything works fine I can change the columns.
Any idea, is it a known bug or I am missing something?
To avoid confusion getItems looks like this in a sessionscoped bean:
@Named
@SessionScoped
public class MyBean extends DataModel<E> implements Serializable {
private List<E> items;
...
public List<E> getItems () {
return items;
}
Upvotes: 0
Views: 759
Reputation: 21
Actually org.primefaces.event.ReorderEvent seems not to be allowed for column reordering but only for row reordering. You should use an AjaxBehaviorEvent as parameter of your method like :
public void onColumReorder(AjaxBehaviorEvent event) {
}
Upvotes: 0