Home » JSF h:inputText

JSF h:inputText

by Online Tutorials Library

JSF <h:inputText>Tag

The JSF <h: inputText> tag is used to render an input field on the web page.

It is used within a <h: form> tag to declare input field that allows user to input data.

The value attribute refers to the name property of a managed bean named User. This property holds the data for the name component. After the user submits the form, the value of the name property in User will be set to the text entered in the field corresponding to this tag.


JSF <h:InputText> Tag Example:

In the following example, we are using a label tag for providing label to inputText tag, a inputText with attributes, a commandButton to represent a submit button. All are enclosed in a <h:form> tag.


JSF renders <h:inputText> tag as below:

Output:

JSF H inputtext tag 1

JSF <h:inputText> Tag Attributes

Attribute name Description
id It is an identifier for this component. This id must be unique. You can use it to access HTML element in CSS and JS file.
value It is used to collect present value of the inputText.
class It gives class name to the component. It is used to access component from CSS and JS file.
maxlength The maximum number of characters that may be entered in this field.
alt Alternate textual description of the element rendered by this component.
accesskey Access key that, when pressed, transfers focus to this element. It varies browser to browser.
size The number of characters used to determine the width of this field .
required It indicates that the user is required to provide a submitted value for this input component.
requiredMessage If required attribute is set to true, the message description provided in the requiredMessage is display to the web page.
style It is used to apply CSS for the component.
rendered It is used to render the component. The default value for this property is true.
convertor It is used to converter instance registered with this component.
readonly It indicates that this component prohibits changes by the user. You can make component readonly by passing readonly as a value of this attribute. eg. readonly = “readonly”

Next TopicJSF h:outputText

You may also like