jsf - How to pass selected column values to a method? -


i need in passing selected row columns' values in <p:datatable> method. in code, getting incorrect values , of them null, can please help.

my datatable code is:

<p:datatable id="pendingrequests" var="hr" value="#{hrd.pendingrequests}">     <p:column headertext="request date">         <h:outputtext value="#{hr.requestdate}"/>     </p:column>      <p:column headertext="request no.">         <h:outputtext value="#{hr.reqno}"/>     </p:column>      <p:column headertext="employee code">         <h:outputtext value="#{hr.employeecode}"/>     </p:column>      <p:column>         <f:facet name="header">view</f:facet>          <p:lightbox style="align:center;" iframe="true" width="1200px" height="600px">             <h:outputlink value="#{hr.link}">                 <p:commandbutton icon="ui-icon-search" actionlistener="#{hrd.hrcess}">                     <f:setpropertyactionlistener target="#{hrd.employeecode}" value="#{hr.employeecode}"/>                     <f:setpropertyactionlistener target="#{hrd.reqno}" value="#{hr.reqno}"/>                 </p:commandbutton>             </h:outputlink>         </p:lightbox>     </p:column> </p:datatable> 

however if clicked on <p:commandbutton> , check printed values of employeecode , reqno. in hrcess() method, find employeecode , reqno. wrong.

and here code in bean:

@postconstruct public void init() {     listpendingrequests = new arraylist<pendingrequests>();      try {         //sql statement         while (result.next()) {             pendingrequests pendinglist = new pendingrequests();             requestdate = result.getstring("ecw_req_dt");             reqno = result.getstring("ecw_req_seq_no");             employeecode = result.getstring("ecw_emp_cd");             pendinglist.setrequestdate(requestdate);             pendinglist.setreqno(reqno);             pendinglist.setemployeecode(employeecode);             listpendingrequests.add(pendinglist);         }     } catch (exception e) {         system.err.print(e);         e.printstacktrace();     } } 

with jsf 2.2 can pass values method parameters.

public void hrcess(string employeecode, string reqno) 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -