I’m trying to use the primefaces dataExporter to export some data and I have a column that has a persons name and the name is a link to an external website.
Originally I had the following code and then I found this thread which says that h:commandLink is now supported by dataExporter
<p:dataTable var="inv" value="#{personBacker.investigators}" id="tbl" rows="50" effect="true">
<p:column filterBy="#{inv.name}" headerText="Investigator" filterMatchMode="contains">
<h:outputLink value="http://example.com/">
<h:outputText value="#{inv.name}" />
</h:outputLink>
</p:column>
</p:dataTable>
Then I changed my code to this, but now the link doesn’t take me to example.com. From what i found on the interwebs, the commandLink can only use an EL Expression I think.
<p:dataTable var="inv" value="#{personBacker.investigators}" id="tbl" rows="50" effect="true">
<p:column filterBy="#{inv.name}" headerText="Investigator" filterMatchMode="contains">
<p:commandLink action="http://example.com" value="#{inv.name}" />
</p:column>
</p:dataTable>
How can I link to an external site using the h:commandLink or p:commandLink tag?
I don’t know if my suggestion will work in your set-up with the DataExporter but to call an external link from a commandLink/commandButton I use the following in my set-up:
Bean:
Another approach would be trying to set the link as html-tag directly. It schouldn’t be too hard as for you showed in your code that the URL is already known:
I hope this helped, have Fun!