Java Reference
In-Depth Information
In addition to CSS files, we should place any JavaScript files in a subdirectory called
javascript under the resources directory. The file can then be accessed by the
<h:outputScript> tag using javascript as the value of its library attribute and
the filename as the value of its name attribute.
Similarly, images should be placed in a directory called images under the resources
directory. These images can then be accessed by the JSF <h:graphicImage> tag,
where the value of its library attribute will be images and the value of its name
attribute will be the corresponding filename.
Now that we have discussed how to lay out elements on the page and how to access
resources, let's focus our attention into the input and output elements on the page.
The <h:outputLabel> tag generates a label for an input field in the form; the value
of its for attribute must match the value of the id attribute of the corresponding
input field.
The <h:message> tag generates an error message for an input field; the value of its
for field must match the value of the id attribute for the corresponding input field.
The first row in our grid contains an <h:selectOneMenu> tag. This tag generates an
HTML <select> tag on the rendered page.
Every JSF tag has an id attribute. The value for this attribute must be a string
containing a unique identifier for the tag. If we don't specify a value for this
attribute, one will be generated automatically. It is a good idea to explicitly state
the ID of every component; since this ID is used in runtime error messages, affected
components are a lot easier to identify if we explicitly set their IDs.
When using the <h:label> tags to generate labels for input fields or when using
the <h:message> tags to generate validation errors, we need to explicitly set the
value of the id tag, since we need to specify it as the value of the for attribute
of the corresponding <h:label> and <h:message> tags.
Every JSF input tag has a label attribute. This attribute is used to generate
validation error messages on the rendered page. If we don't specify a value for
the label attribute, the field will be identified in the error message by the value
of its id attribute.
 
Search WWH ::




Custom Search