0

I have a datatable which consists of a list of names taken from database. These names are displayed using the commandlink. The code is shown below:

      <h:form id="formp">
              <p:dataTable id="listpat" var="p" value="#{loginBean.patient}"> 
                    <p:column> 
                        <p:commandLink value="#{p.firstname} #{p.lastname}" action="#     {loginBean.getPatientID(p.firstname)}" onclick="tabview.select(1);">
                        </p:commandLink>
                    </p:column>
              </p:dataTable>                  
      </h:form>

clicking the commandlink calls a method getPatientID(p.firstname) in the backing bean. I realised the name on the link i click on does not correspond to what is in the backing bean. (e.g. the name clicked on in the commandlink is not the same as the name gotten by passing into the backing bean). What could be the reason? How can i solve it?

public void getPatientID(String fname) {
    System.out.println(fname);
}
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
user1097856
  • 159
  • 3
  • 15

1 Answers1

0
<p:commandLink value="#{p.firstname} #{p.lastname}" action="#{loginBean.getPatientID(p.firstname)}" onclick="tabview.select(1);">
<f:setPropertyActionListener target="#{loginBean.patient.firstname}" value="#{p.firstname}"
                    </p:commandLink>

maybe this will work

tddiaz
  • 111
  • 1
  • 3
  • 12