background image

The outputLink Tag

<< The outputLabel Tag | The inputSecret Tag >>
<< The outputLabel Tag | The inputSecret Tag >>

The outputLink Tag

rendered=
"false"
binding=
"#{cashier.specialOfferText}"
value=
"#{bundle.DukeFanClub}" />
</h:outputLabel>
...
Rendering a Hyperlink with the outputLink Tag
The outputLink tag is used to render a hyperlink that, when clicked, loads another page but
does not generate an action event. You should use this tag instead of the commandLink tag if you
always want the URL (specified by the outputLink tag's value attribute) to open and do not
have to perform any processing when the user clicks on the link. The Duke's Bookstore
application does not utilize this tag, but here is an example of it:
<h:outputLink value=
"javadocs">
Documentation for this demo
</h:outputLink>
The text in the body of the outputLink tag identifies the text the user clicks to get to the next
page.
Displaying a Formatted Message with the outputFormat Tag
The outputFormat tag allows a page author to display concatenated messages as a
MessageFormat
pattern, as described in the API documentation for java.text.MessageFormat
(see
http://java.sun.com/javase/6/docs/api/java/text/MessageFormat.html
). Here is
an example of an outputFormat tag from the bookshowcart.jsp page of the Duke's Bookstore
application:
<h:outputFormat value=
"#{bundle.CartItemCount}">
<f:param value=
"#{cart.numberOfItems}"/>
</h:outputFormat>
The value attribute specifies the MessageFormat pattern. The param tag specifies the
substitution parameters for the message.
In the example outputFormat tag, the value for the parameter maps to the number of items in
the shopping cart. When the message is displayed on the page, the number of items in the cart
replaces the {0} in the message corresponding to the CartItemCount key in the bundle
resource bundle:
Your shopping cart contains
" + "{0,choice,0#no items|1#one item|1< {0} items
This message represents three possibilities:
Your shopping cart contains no items.
Your shopping cart contains one item.
Adding UI Components to a Page Using the HTML Component Tags
The Java EE 5 Tutorial · September 2007
334