10.12.2012 Views

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Adding the view and form Tags<br />

All <strong>Java</strong>Server Faces pages are represented by a tree of components, called a view. <strong>The</strong> view tag<br />

represents the root of the view. All <strong>Java</strong>Server Faces component tags must be inside of a view<br />

tag, which is defined in the core tag library.<br />

<strong>The</strong> form tag represents an input form component, which allows the user to input some data<br />

and submit it to the server, usually by clicking a button. All UI component tags that represent<br />

editable components (such as text fields and menus) must be nested inside the form tag. In the<br />

case of the greeting.jsp page, some of the tags contained in the form are outputText,<br />

inputText, commandButton, and message. You can specify an ID for the form tag. This ID maps<br />

to the associated form UI component on the server.<br />

With the view and form tags added, our page looks like this (minus the HTML and HEAD tags):<br />

<br />

<br />

<br />

<br />

<br />

<br />

Adding a Label Component<br />

<strong>The</strong> outputText tag represents a label. <strong>The</strong> greeting.jsp page has two outputText tags. One<br />

of the tags displays the number 0. <strong>The</strong> other tag displays the number 10:<br />

<br />

<br />

<strong>The</strong> value attributes of the tags get the values from the minimum and maximum properties of<br />

UserNumberBean using value expressions, which are used to reference data stored in other<br />

objects, such as beans. See “Backing Beans” on page 307 for more information on value<br />

expressions.<br />

With the addition of the outputText tags (along with some static text), the greeting page looks<br />

like the following:<br />

<br />

<br />

<br />

<br />

Hi. My name is Duke. I’m thinking of a number from<br />

to<br />

.<br />

A Simple <strong>Java</strong>Server Faces Application<br />

Chapter 10 • <strong>Java</strong>Server FacesTechnology 289

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!