I am using PF 3.0RC1 with JSF 2.0.
I have a datatable and on each row I have a delete button. As soon as I press the delete the corresponding row gets deleted from db but the datatable does not get refreshed. It still shows the old set of rows. How can I get the datatable to be refreshed?
Here is the code
<h:form id="form">
<p:dataTable value="#{myController.displayList}" var="item" id="tbl">
<p:column>
<p:commandButton image="icon icon-delete"
id="del" action="#{myController.del}"
update="@form">
<f:setPropertyActionListener value="#{item}"
target="#{myController.selected}" for="del"/>
</p:commandButton>
</p:column>
</p:dataTable>
</h:form>
The displayList is
private List<Image> displayList = new ArrayList<Image>();
public List<Image> getDisplayList() {
Student std = (Student) getSelected;
displayList = this.ejbFacade.getImages(std.getId()); // this method gets the list of images which has status = 1
return displayList;
}
public void setDisplayList(List<Image> displayList) {
this.displayList = displayList;
}
//this is the del method which sets the flag for image to 0 (when del icon is pressed from view)
public void del() {
selected.setActiveStatus(0);
MyController myController = (MyController) facesContext.getApplication().getELResolver().
getValue(facesContext.getELContext(), null, "myController");
displayList.clear();
myController.getFacade().edit(selected);
}