0

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;

  ---

}
Cœur
  • 37,241
  • 25
  • 195
  • 267
Bikram
  • 828
  • 8
  • 21
  • Do you have a converter for Course? – Jaqen H'ghar Apr 18 '15 at 09:20
  • Opps that's what was missing. Thanks for your help. It solved my problem. – Bikram Apr 18 '15 at 15:41
  • This problem is 2-fold. The 1st problem is answered as point 3 in the duplicate. This should in turn have exposed a 2nd problem: a conversion/validation error which has a quite googlable/searchable message. – BalusC Apr 20 '15 at 06:38

0 Answers0