To add an Input component to your page that allows a user to enter
a line of text and have that text validated:
- Drag an Input component from the palette onto a Faces JSP.
- In the Properties view for the Input component, h:inputText,
optionally, change the ID that was automatically generated
for the input component and set the style properties and style classes.
- From the Format list, select String.
- To validate the value entered in this field on the server, click
the Validation tab in the Properties view:
- To require the user to enter a value, select Value
is required.
- The validation has two options:
- Use simple validation - Allows you to set a minimum
and maximum number of character values for the input. When submitted to the
server, the input is validated to ensure it is within this range. The Constraint drop
down allows you select from a predefined set of regular expressions. The default
is blank (no constraint). Use the Click to create/edit custom validation
code to define a custom regular expression.
- Use advanced validation - Allows you to define
a validation using JSF expression syntax. When defining the constraint you
can use standard Javaâ„¢ or JavaScriptâ„¢ regular expression syntax.
- Select Display validation error messages in an error
message control to automatically create a Display Error component
that displays an error message if validation fails on the input component.
Optionally, select Click to create/edit custom validation
code to switch to the Quick Edit view and create custom validation
code.
- To validate the value entered in this field on the client, click
the Behaviour tab in the Properties view:
- Select Validate field value in the browser.
- On the onblur Actions and onfocus
Actions tabs, for On success and On
failure select a class for the Apply CSS classes field
and select an action from the Run action list.
Optionally, click Additional behaviors can be supplied
in the onsuccess, onerror, onfocussuccess and onfocuserror events in the QuickEdit
view to create custom behaviour code.
- To prevent input from the user, on the Behavior tab,
select Control is disabled or Control is
read-only.
- To navigate to the next field on the page after the user finishes
entering information, select Auto advance to next field.
This required that the After user types ___ characters is
set.
- To restrict the number of characters entered from the client, enter
a value in the After user types ___ characters field.
- To ensure your component is accessible, you can set a keyboard
access key, determine tabbing order, and add a component title. On the Accessibility tab:
as an access key (clicking this key at run time causes the component to gain
focus), a tabbing order for the component, and a title (which can give the
user a tip at run time).
- Select a character from the Access key list.
Clicking this keyboard key at runtime gives focus to the component.
- Type a number for the Tab order index.
This number determines where the component is in the tabbing order at runtime.
- Type a Title. This value displays with
the component at runtime.