Form
Creates a main container for other components and is automatically added when an input component is added to the page. The form defines what is submitted when a submit button or JavaScriptâ„¢ submit is executed.
Component class
javax.faces.component.html.HtmlForm
Component at design time
Drag and drop an
Form component onto the page:
The
Form component looks like this on the page:
Component at runtime
There is no visible runtime rendering of the
Form component.
Properties and All Attributes views
The Properties view for a component shows the most common set of attributes you can set on a component, and, depending on the component, you might also see options for adding controls, actions, or other components. To open the Properties view, click
Window | Show View | Properties.
These common attributes for the Form component display on the h:form, Keyboard Assist, and Hidden Fields tabs in the Properties view. See the All Form attributes table for a complete list of attributes. Additional configuration options for display and accessibility are on the h:form>Keyboard Assist and h:form>Hidden Fields tabs:
Table 1. Form configuration options Configuration option
Description
Assign actions to the specified keystrokes.
Specifies key strokes, actions and targets of those actions within the form component. Key strokes and actions are chosen from drop down lists. The targets are selected from a drop down list populated with input fields present within the form. Whenever the key is pressed within the form, the action is executed.
Hidden Fields
Displays all current
Input - Hidden components within the form and allows you to add, remove, and modify hidden fields.
Select the content of this field
Specifies that the field chosen to have focus should also initially have its contents selected.
Set focus when the page is initially displayed
Specifies the field that will have the initial focus when the page is displayed.
First field in page or
Specific Fields (identified by their ID) may be specified.
The All Attributes view shows a table of all the attributes you can set on a component, which includes those attributes you can access from the Properties view. To switch to the All Attributes view, click the
All Attributes icon in the upper right corner of the Properties view.
Table 2. All Form attributes Attribute name
Represented in Properties view by
Description
accept
h Specifies the types of files, separated by commas, that the component will allow.
acceptcharset
Not represented
The character set in which the response to the client is expected. Standard HTML attr. See the HTML form tag: This attribute specifies the list of character encodings for input data that is accepted by the server processing this form. The value is a space-delimited and/or comma-delimited list of charset values. The client must interpret this list as an exclusive-or list, that is, the server is able to accept any single character encoding per entity received.
binding
Not represented
An expression that binds the component's instance (usually a user interface component) to a bean property (usually in the backing file).
dir
Not represented
Specifies the component's direction when rendered at runtime. The values can be either:
If the direction is not specified, a direction appropriate to the encoding of the component is used.
- ltr - left to right
- rtl - right to left
enctype
Not represented
Specifies the content type used to submit the form.
id
ID
Assigns a name to a component. Should be a unique name within a JSP.
lang
Not represented
The language of the component's value(s) and text content. If omitted, the language is inherited from the containing tags (notably the view. Specified as an ISO-standard language abbreviation code. For example, "en" for English, "en-US" for American English, "fr" for French, "de" for German.
Note: This does not "translate" the text in the component, rather, it identifies the language of the component so that operations such as searching, sorting, collating and the like are done correctly.
rendered
Not represented
Can be set to true or false:
- false - Component will not be rendered to the browser at runtime.
- true - Component will get rendered. This is the default value.
style
Style: Props
Specifies CSS style information for the component (for example, style="font-size : 8pt ; color : red"). Defines the properties (such as font and color) of the selected component. This may be done manually, or by clicking the button and selecting the desired properties from within the window.
styleClass
Style: Classes
Space-separated list of CSS style classes to be applied when this element is rendered. This value must be passed through as the class attribute on generated markup. Defines the classes (such as style sheets) of the selected component. This may be done manually, or by clicking the button and selecting the desired Classes from within the window.
target
Not represented
Assigns the target frame within a frameset that a page should be loaded into when a component is clicked.
title
Not represented
Specifies the title text, shown in browser as a tooltip at runtime. Used by a browser as the alternative text of a component if the alternative text is not specified.