0
votes

Hello I have editable datatable and i want to get new values from that row so, following is a code that I have ....

This code For DataTable

Row Editing

                                  <f:facet name="People">
                                      <p:outputPanel>
                                          <h:outputText value="Search all fields:" />
                                          <p:inputText id="globalFilter"  onkeyup="PF('peoplesTable').filter()" style="width:150px" />
                                      </p:outputPanel>
                                  </f:facet>                                      

                                  <p:ajax event="rowEdit" listener="#{personInformation.onRowEdit}" update="dt" />
                                  <p:ajax event="rowEditCancel" listener="#{personInformation.onRowCancel}"  />   
                                  <p:ajax event="rowSelect" listener="#{personInformation.onRowSelect}" />
                                  <p:ajax event="rowUnselect" listener="#{personInformation.onRowUnselect}" /> 

                                  <p:column style="width:16px">
                                      <p:rowToggler />
                                  </p:column>

                                  <p:column  headerText="व्यक्ती क्र." filterBy="#{per.id}" filterMatchMode="contains" style="width:30px;" >                          
                                    <p:cellEditor  >
                                        <f:facet name="output"><h:outputText value="#{per.id}" /></f:facet>
                                        <f:facet name="input"><h:outputText value="#{per.id}" style="width:100%" /></f:facet>
                                    </p:cellEditor>
                                </p:column>

                                  <p:column headerText="नाव" filterBy="#{per.name}" filterMatchMode="contains" >
                                    <p:cellEditor>
                                        <f:facet name="output"><h:outputText value="#{per.name}" /></f:facet>
                                        <f:facet name="input"><p:inputText value="#{per.name}" style="width:100%" label="Name"/></f:facet>
                                    </p:cellEditor>
                                </p:column>
                                  <p:column headerText="पत्ता" filterBy="#{per.address}" filterMatchMode="contains" >
                                    <p:cellEditor>
                                        <f:facet name="output"><h:outputText value="#{per.address}" /></f:facet>
                                        <f:facet name="input"><p:inputText value="#{per.address}" style="width:100%" label="Address"/></f:facet>
                                    </p:cellEditor>
                                </p:column>                                    
                                  <p:column headerText="मोबाईल नंबर" filterBy="#{per.mobilenumber}" filterMatchMode="contains"  >
                                    <p:cellEditor>
                                        <f:facet name="output"><h:outputText value="#{per.mobilenumber}" /></f:facet>
                                        <f:facet name="input"><p:inputText value="#{per.mobilenumber}" style="width:100%" label="Mobile Number"/></f:facet>
                                    </p:cellEditor>
                                </p:column>
                                  <p:column headerText="भेटीचे कारण" filterBy="#{per.reason}" filterMatchMode="contains" >
                                    <p:cellEditor>
                                        <f:facet name="output"><h:outputText value="#{per.reason}" /></f:facet>
                                        <f:facet name="input"><p:inputText value="#{per.reason}" style="width:100%" /></f:facet>
                                    </p:cellEditor>
                                </p:column>                                                 
                                  <p:column headerText="भेटीचे वेळ" style="width:200px;" filterBy="#{per.d}" filterMatchMode="contains" >
                                    <p:cellEditor>
                                        <f:facet name="output"><h:outputText value="#{per.d}" /></f:facet>
                                        <f:facet name="input"><h:outputText value="#{per.d}" /></f:facet>
                                    </p:cellEditor>
                                </p:column>                                                  
                                  <p:column style="width:32px">
                                      <p:rowEditor />
                                  </p:column>

                                  <p:rowExpansion  >

                                      <p:panelGrid  columns="2" columnClasses="label,value" style="margin-left: 300px;width:300px">
                                          <h:outputText value="व्यक्ती क्र." />
                                          <h:outputText value="#{per.id}" />

                                          <h:outputText value="नाव" />
                                          <h:outputText value="#{per.name}" />

                                          <h:outputText value="पत्ता" />
                                          <h:outputText value="#{per.address}" />

                                          <h:outputText value="मोबाईल नंबर" />
                                          <h:outputText value="#{per.mobilenumber}" />

                                          <h:outputText value="भेटीचे कारण" />
                                          <h:outputText value="#{per.reason}" />

                                          <h:outputText value="भेटीचे वेळ" />
                                          <h:outputText value="#{per.d}" />
                                      </p:panelGrid>
                                  </p:rowExpansion>
                            </p:dataTable>

and backing Bean in which i want to display new edited values...

public void onRowSelect(SelectEvent event)
     {

         System.out.println(event.getObject().toString());      
         DataTable objDataTable = (DataTable) event.getSource();
         System.out.println("Get Row Data : "+objDataTable.getRowData("id"));
         PersonBean pb=new PersonBean();
         pb=(PersonBean)objDataTable.getRowData();
         int id=pb.getId();
         String name=pb.getName();
         String address=pb.getAddress();
         String mobilenumber=pb.getMobilenumber();
         String reason=pb.getReason();


}
1

1 Answers

0
votes

if you want to get new value from datatable once it has been updated you should use rowEdit event instead.

<p:ajax event="rowEdit" listener="#{bean.listener}"/>

<p:column>
   <p:cellEditor>
      <f:facet name="output">
           <h:outputText value="#{per.name}"/>
       </f:facet>
       <f:facet name="input">
             <h:inputText value="#{per.name}" required="true"/>
        </f:facet>
   </p:cellEditor>
  </p:column>

 public void update(RowEditEvent event) {
   // use event.getObject() here
}