0

I have a DataModel Table with Command Links to Navigate to another Page On Clicking.

But the Navigation is not Occurring in DataModel Table, as when i click on the link it is selecting the whole Row as it is a DataModel.

What should i do in-order to make it work as a Command Link.

My Piece of Code:

<p:dataTable id="studentDtTble" var="studmodel" value="#{studentController.dataModelList}">
    <p:columnGroup type="header">
        <p:row>
                <p:column headerText="StudentId"></p:column>
                <p:column headerText="StudentName"></p:column> 
                <p:column headerText="Add" ></p:column>     
        </p:row>
    </p:columnGroup>
        <p:column>
            <p:commandLink id="ajax" update="">  
                <h:outputText value="#{studmodel.studentId}" styleClass="txtlink" />
            </p:commandLink>
        </p:column>
        <p:column>
           <h:outputText value="#{studmodel.studentName}" />
        </p:column>
        <p:column >
            <p:selectBooleanCheckbox value="#{studmodel.add}" />
        </p:column>
</p:dataTable>

When i Click on the StudentId Link then it Should navigate to Student Information.jsf Page. Which is not Happening.

For that to happen i Wrote a Method in Controller

studentInfo(studentID){
 ..Navigate to the Student Info Page ..
}

But i am unable to Call the Method with that studentId because it is selecting as a row . Any Suggestions

09Q71AO534
  • 4,300
  • 13
  • 44
  • 68
  • possible duplicate of [JSF 2.X Passing parameter between two xhtml pages](http://stackoverflow.com/questions/11539485/jsf-2-x-passing-parameter-between-two-xhtml-pages) – kolossus Dec 24 '13 at 17:03

1 Answers1

0

Selected whole row as you click on it is a default behaviour of the datatable. You can use selection attribute of the datatale and pointing it to an object like this

<p:dataTable id="studentDtTble" var="studmodel" value=#{studentController.dataModelList}"
  selection="#{studentController.selectedItem}>

and in the controller you should have a mapping element Student selectedItem, I am assuming Student as your object. Your method should have a String as a return type to perform navigation. you can define a navigation rule in faces-config.xml.

Or

You can use action attribute of the command Link(action method must have String as a return type) and pass student id like below using

<f:setPropertyctionListener value="#{studmodel.studentId}" target="any string
  in controller /> as a child element in commandLink

Hope this hepls :)

Srikanth Ganji
  • 1,127
  • 1
  • 13
  • 29