10.12.2012 Views

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Adding UI Components to a Page Using the HTML ComponentTags<br />

332<br />

rendered="false"<br />

binding="#{cashier.specialOfferText}"<br />

value="#{bundle.DukeFanClub}" /><br />

<br />

...<br />

Rendering a Hyperlink with the outputLink Tag<br />

<strong>The</strong> outputLink tag is used to render a hyperlink that, when clicked, loads another page but<br />

does not generate an action event. You should use this tag instead of the commandLink tag if you<br />

always want the URL (specified by the outputLink tag’s value attribute) to open and do not<br />

have to perform any processing when the user clicks on the link. <strong>The</strong> Duke’s Bookstore<br />

application does not utilize this tag, but here is an example of it:<br />

<br />

Documentation for this demo<br />

<br />

<strong>The</strong> text in the body of the outputLink tag identifies the text the user clicks to get to the next<br />

page.<br />

Displaying a Formatted Message with the outputFormat Tag<br />

<strong>The</strong> outputFormat tag allows a page author to display concatenated messages as a<br />

MessageFormat pattern, as described in the API documentation for java.text.MessageFormat<br />

(see http://java.sun.com/javase/6/docs/api/java/text/MessageFormat.html). Here is<br />

an example of an outputFormat tag from the bookshowcart.jsp page of the Duke’s Bookstore<br />

application:<br />

<br />

<br />

<br />

<strong>The</strong> value attribute specifies the MessageFormat pattern. <strong>The</strong> param tag specifies the<br />

substitution parameters for the message.<br />

In the example outputFormat tag, the value for the parameter maps to the number of items in<br />

the shopping cart. When the message is displayed on the page, the number of items in the cart<br />

replaces the {0} in the message corresponding to the CartItemCount key in the bundle<br />

resource bundle:<br />

Your shopping cart contains " + "{0,choice,0#no items|1#one item|1< {0} items<br />

This message represents three possibilities:<br />

■ Your shopping cart contains no items.<br />

■ Your shopping cart contains one item.<br />

<strong>The</strong> <strong>Java</strong> <strong>EE</strong> 5<strong>Tutorial</strong> • June 2010

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!