谢谢!
Adding the view and form tags
All JavaServer Faces pages are represented by a tree of components,called a view. The view tag represents the root of the view. All JavaServer Faces component tags must be insie of a view tag, which is defined in the core tag library.
The form tag represents an input form component, which allows the user to input some data and submit it to the server,usually by clicking a button.All UI component tags the represent editable components(such as text fields and menus) must be nested in side the form tag.In the case of the greeting.Jsp page,some of the tags contained in the form are outputText,inputext,commandButton ,and message . You can specify an ID for the form tag.This ID maps to the associated form UI component on the server.
With the view and form tags added, our page looks like this (minus the HTML and HEAD tags):
… …
Adding a Label component
The outputText tag represents a label.the greting.Jsp page has two outputText tags.One of the tags displays the number0.The other tag displays the number 10:
… …
The value attributes of the tags get the values from the minimum and maximum properties of UserNumberBean using value expressions, which are used to reference data stored in other objects,such as beans.See”Backing Beans” on page 309 for more information on value expressions.
With the addition of the outputText tags(along with some static text),the greeting page looks like the following:
… …
Adding an Image
To display images on page,you use the graphicImage tag.The urlattribute of the tag specifies the path to the image file.Let’s add Duke to the page using a graphicImage tag:
… …
Adding a TextField
The imputText tag represents a text field component.In the guessNumber example,this text field takes an integer input value.The instance of this tag included in greeting.Jsp has three attributes:id,laber,and value
… …
The id attribute corresponds to the ID of the component object represented by this tag.In this case,an id attribute is required because the message tag(which is used to display validation error messages) needs it to refer to the user No component.
The label attribute specifies the name to be used by error messages to refer to the component. In this example, label is set to User Number.As an example,if a user were to enter 23, the error message that would be displayed is :
User Number:Validation Error: Value is greater than allowable maximum of 10.
The value attribute binds the userNo component value to the bean property UserNumberBean.userNumber,which holds the data entered into the text field..
After adding the imputText tag, the greeting page looks like the following: