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 , that means that the value is read at runtime from a JSF
managed bean. In our example, the value binding expression #{registrationBean.
salutation} is used. What will happen is at runtime JSF will look for a managed
bean named registrationBean , and look for an attribute named salutation on
this bean, 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 the <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 <h:inputText> tags, this tag generates an HTML
input field of type text , which accept a single line of typed text as input. We
explicitly set the id attribute of all of our <h:inputText> fields, this 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, this results in
more user-friendly error messages.
Some of our <h:inputText> fields require a value, these fields have their required
attribute set to true , each JSF input field has a required attribute, if we need to
require the user to enter a value for this attribute, then 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 adding several tags into a single cell of an <h:panelGrid> .
Any tags placed inside this tag are 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.
 
Search WWH ::




Custom Search