The primefaces rowEditor event works for me when I have String, Integer and Enums to edit in the dataTable but when I tries to update the object list, the onRowEdit event does not execute. I have provided the code below, let me know if more information is needed.
enviorment PF5.2, JSF 2.2, GF 4.0 and its maven project
student.xhtml page
<p:dataTable id="dataTable" value="#{student.students}" var="item" editable="true">
<p:column headerText="course">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{item.course.name}" />
</f:facet>
<f:facet name="input">
<h:selectOneMenu value="#{item.course}">
<f:selectItems value="#{student.courses}" var="_course" itemValue="#{_course}" itemLabel="#{_course.name}"/>
</h:selectOneMenu>
</f:facet>
</p:cellEditor>
</p:column>
<p:ajax event="rowEdit" listener="#{student.onRowEdit}" update="dataTable"/>
<p:ajax event="rowEditCancel" listener="#{student.onRowCancel}" update="dataTable" />
<p:column style="width:32px">
<p:rowEditor/>
</p:column>
bean
@Named("student")
@ViewScoped
public class StudentManager implements Serializable {
private static final long serialVersionUID = 9196263323752494128L;
private List<Students> students = new ArrayList<>();
private List<Course> courses = new ArrayList<>();
@PostConstruct
public void init() {
students = service.getStudents();
courses = service.getCources();
}
public void onRowEdit(RowEditEvent event) {
//do something
}
public void onRowCancel(RowEditEvent event) {
//do nothing
}
//getters and setters
------
------
}
Objects
@Entity
@Table(name="student")
public class Student implements Serializable {
---
private Integer id;
private String firstName;
private String lastName;
private Course course;
---
}
@Entity
@Table(name="course")
public class Course implements Serializable {
---
private Integer id;
private String courseName;
---
}