The Java EE 5 Tutorial

Rendering a Hyperlink with the commandLink Tag

The commandLink tag represents an HTML hyperlink and is rendered as an HTML <a> element. The commandLink tag is used to submit an action event to the application. See Implementing Action Listeners for more information on action events.

A commandLink tag must include a nested outputText tag, which represents the text the user clicks to generate the event. The following tag is from the chooselocale.jsp page from the Duke’s Bookstore application.

<h:commandLink id="NAmerica" action="bookstore"
     <h:outputText value="#{bundle.English}" />

This tag will render the following HTML:

<a id="_id3:NAmerica" href="#"
     return false;">English</a>

Note –

The commandLink tag will render JavaScript. If you use this tag, make sure your browser is JavaScript-enabled.