Java Reference
In-Depth Information
Each JSF input field has a value attribute; in the case of <h:selectOneMenu> ,
this attribute indicates which of the options in the rendered <select> tag will be
selected. The value of this attribute must match the value of the itemValue attribute
of one of the nested <f:selectItem> tags. The value of this attribute is usually a
value binding expression, which means that the value is read at runtime from a CDI
named bean. In our example, the value binding expression #{registrationBean.
salutation} is used. At runtime, JSF will look for a CDI named bean called
registrationBean and look for an attribute named salutation on this bean. Then,
the getter method for this attribute will be invoked, and its return value will be used
to determine the selected value of the rendered HTML <select> tag.
Nested inside <h:selectOneMenu> , there are a number of <f:selectItem> tags.
These tags generate HTML <option> tags inside the HTML <select> tag generated
by <h:selectOneMenu> . The value of the itemLabel attribute is the value that the
user will see while the value of the itemValue attribute will be the value that will be
sent to the server when the form is submitted.
All other rows in our grid contain the <h:inputText> tag. This tag generates an
HTML input field of type text , which accepts a single line of typed text as input.
We explicitly set the id attribute of all of our <h:inputText> fields, which allows us
to refer to them from the corresponding <h:outputLabel> and <h:message> fields.
We also set the label attribute for all of our <h:inputText> tags, which results in
user-friendly error messages.
Some of our <h:inputText> fields require a value. These fields have their required
attributes set to true , and each JSF input field has a required attribute. If we need
the user to enter a value for this attribute, we need to set this attribute to true . This
attribute is optional; if we don't explicitly set a value for it, then it defaults to false .
In the last row of our grid, we added an empty <h:panelGroup> tag. The purpose of
this tag is to allow you to add several tags into a single cell of a panel grid. Any tag
placed inside this tag is placed inside the same cell of the grid where <h:panelGrid>
is placed. In this particular case, all we want to do is to have an empty cell in the
grid so that the next tag, <h:commandButton> , is aligned with the input fields in
the rendered page.
The <h:commandButton> tag is used to submit a form to the server. The value of its
value attribute is used to generate the text of the rendered button. The value of its
action attribute is used to determine what page to display after the button is clicked.
 
Search WWH ::




Custom Search