The Java EE 6 Tutorial, Volume I

Adding a Form Component

A h:form tag represents an input form, which includes child components that can contain data, that is either presented to the user or submitted with the form.

Figure 7–1 shows a typical login form in which a user enters a user name and password, then submits the form by clicking the Login button.

Figure 7–1 A Typical Form

Screen capture of form with User Name and Password text
fields and a Login button.

The h:form tag represents the Form component on the page and encloses all the components that display or collect data from the user, as shown here:

... other JavaServer Faces tags and other content...

The h:form tag can also include HTML markup to lay out the components on the page. Note that the h:form tag itself does not perform any layout; its purpose is to collect data and to declare attributes that can be used by other components in the form.

A page can include multiple h:form tags, but only the values from the form submitted by user will be included in the postback request.