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

<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://xmlns.jcp.org/jsf/html"
	xmlns:f="http://xmlns.jcp.org/jsf/core" xmlns:ui="http://xmlns.jcp.org/jsf/facelets">

	<!-- Example 1: Specifying text for the hyperlink -->
	<h:form>
		<h:outputLink  target="_blank"
			value="https://www.liferay.com/community/liferay-projects/liferay-faces">
			<h:outputText value="#{i18n['text-for-a-link']}" />
		</h:outputLink>
	</h:form>

	<!-- Example 2: Specifying an image for the hyperlink -->
	<h:form>
		<h:outputLink target="_blank" value="https://www.liferay.com/community/liferay-projects/liferay-faces">
			<h:graphicImage value="#{resource['images:jsf-logo-small.png']}" />
		</h:outputLink>
	</h:form>

	<!-- Example 3: Specifying URL parameters with f:param -->
	<h:form>
		<h:outputLink target="_blank" value="https://www.google.com/search">
			<h:outputText value=" #{i18n['text-for-a-link']} " />
			<h:graphicImage value="#{resource['images:jsf-logo-small.png']}" />
			<f:param name="q" value="liferay faces" />
		</h:outputLink>
	</h:form>

</ui:composition>
Liferay Faces Bridge Implementation 5.0.0 + Showcase Common 3.1.1 + Liferay Faces Util 3.4.1 + Mojarra 2.2.20