Java Reference
In-Depth Information
The CSS stylesheet for our example is very simple, therefore it is not shown.
However, it is part of the code download for this chapter.
The value of the library attribute in <h:outputStylesheet> must match the
directory where our CSS file is located, and the value of its name attribute must
match the CSS file name.
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 file name 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 would be "images" and the value of its name
attribute would be the corresponding file name.
Now that we have discussed how to lay out elements on the page and how to access
resources, let's focus our attention on 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.
<h:message> 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> . 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 <h:label> tags to generate labels for input fields, or when using
<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, then the field will be identified in the error message by its ID.
 
Search WWH ::




Custom Search