Note

  • h:outputlink is intended to be used to render a simple <a href="...">hyperlink</a> that requests a URL via HTTP GET.
  • h:link is intended to be used to render a hyperlink that navigates to other JSF views via HTTP GET, or perhaps to re-render the same view with different view parameters via f:param child tags.

h:outputLink

HtmlOutputLink is a UIOutput component that renders an <a> element (hyperlink).

General Usage

The value of the component is rendered as the href attribute and the children of the component are rendered as the text/content of the hyperlink.

Source Code

  1. <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://xmlns.jcp.org/jsf/html"
  2. xmlns:f="http://xmlns.jcp.org/jsf/core" xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
  3.  
  4. <!-- Example 1: Specifying text for the hyperlink -->
  5. <h:form>
  6. <h:outputLink target="_blank"
  7. value="https://www.liferay.com/community/liferay-projects/liferay-faces">
  8. <h:outputText value="#{i18n['text-for-a-link']}" />
  9. </h:outputLink>
  10. </h:form>
  11.  
  12. <!-- Example 2: Specifying an image for the hyperlink -->
  13. <h:form>
  14. <h:outputLink target="_blank" value="https://www.liferay.com/community/liferay-projects/liferay-faces">
  15. <h:graphicImage value="#{resource['images:jsf-logo-small.png']}" />
  16. </h:outputLink>
  17. </h:form>
  18.  
  19. <!-- Example 3: Specifying URL parameters with f:param -->
  20. <h:form>
  21. <h:outputLink target="_blank" value="https://www.google.com/search">
  22. <h:outputText value=" #{i18n['text-for-a-link']} " />
  23. <h:graphicImage value="#{resource['images:jsf-logo-small.png']}" />
  24. <f:param name="q" value="liferay faces" />
  25. </h:outputLink>
  26. </h:form>
  27.  
  28. </ui:composition>
Liferay Faces Bridge Implementation 5.0.0 + Showcase Common 3.1.1 + Liferay Faces Util 3.4.1 + Mojarra 2.2.20