0

I've got this table:

<p:dataTable value="#{requestBean.requestsList}" var="requestClass" style="width:50px;" id="requestList">  
    <p:column>  
        <f:facet name="header">  
            <h:outputText value="ID" />  
        </f:facet>  
        <h:outputText value="#{requestClass.requestID}" />  
    </p:column>  

    <p:column>  
        <f:facet name="header">  
            <h:outputText value="Status" />  
        </f:facet>  
        <h:outputText value="#{requestClass.requestStatus}" />  
    </p:column>  

    <p:column>  
        <f:facet name="header">  
            <h:outputText value="Details" />  
        </f:facet>  
        <h:outputText value="#{requestClass.requestTitle}" />  
    </p:column>
</p:dataTable>  

Now the rows display the data properly but I want to be able to click on a record ID. When I do I go to another page e.g. review.xhtml where the url parameter would be that ID. So something like this: review.xhtml?id="clicked request". How is that done?

Update: I tried this and it did kinda work, but is it correct in practice?

<p:column>  
    <f:facet name="header">  
        <h:outputText value="ID" />  
    </f:facet> 
    <a href="review.xhtml?id=#{requestClass.requestID}">
        <h:outputText value="#{requestClass.requestID}" />  
    </a>
</p:column>  
Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
sys_debug
  • 3,883
  • 17
  • 67
  • 98

2 Answers2

6

Try this one:

<p:column>  
   <f:facet name="header">  
      <h:outputText value="ID" />  
   </f:facet>  
   <h:link outcome="review" value="#{requestClass.requestID}" >
      <f:param name="id" value="#{requestClass.requestID}" />
   </h:link>  
</p:column>  
Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
Mr.J4mes
  • 9,168
  • 9
  • 48
  • 90
  • hmmm this is not clear? where does the url go? and id passing in URL? – sys_debug Dec 18 '11 at 12:51
  • 1
    This URL go to the page you specified in the `outcome` attribute and the id you want to pass is in the `f:param` tag. Google the `h:link` and `f:param` tag and you will understand =). – Mr.J4mes Dec 18 '11 at 13:06
  • This seems to work most of the time, but once the data table is filtered, the f:param's value does not get resolved. Any thoughts on how to fix this? – Gowtham Apr 29 '13 at 00:40
2

try this code

<h:outputLink value="#{bean.url}">
    <h:outputText value="Go to another page."/>   
    <f:param name="paramid" value="#{bean.id}" />
</h:outputLink>
Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
Kashif Khan
  • 2,615
  • 14
  • 14
  • bean.url should be replaced with review.xhtml or any other url. paramid should be the name of parameter, in your case it is ID and bean.id should contain the value which you want to pass as parameter. – Kashif Khan Dec 18 '11 at 13:05