The Java EE 5 Tutorial

Adding a Button

The commandButton tag represents the button used to submit the data entered in the text field. The action attribute specifies an outcome that helps the navigation mechanism decide which page to open next. Defining Page Navigation discusses this further.

With the addition of the commandButton tag, the greeting page looks like the following:

<%@ taglib uri="" prefix="h" %>
<%@ taglib uri="" prefix="f" %>
    <h:form id="helloForm1">
        <h2>Hi. My name is Duke. I’m thinking of a number from
         <h:outputText lang="en_US"
             value="#{UserNumberBean.minimum}"/> to
         <h:outputText value="#{UserNumberBean.maximum}"/>.
        Can you guess it?</h2>
        <h:graphicImage id="waveImg" url="/" />
        <h:inputText id="userNo" label="User Number"
                     maximum="#{UserNumberBean.maximum}" />
        <h:commandButton id="submit"
             action="success" value="Submit" />

See Using Command Components for Performing Actions and Navigation for more information on the commandButton tag.