JSF Tutorial - JSF Form_TextArea Example

The h:inputText tag renders an HTML input element of the type "text".

The following JSF code

<h:inputTextarea row="10" col="10" value="Hello World!" readonly="true"/>

is rendered into

<textarea name="j_idt6:j_idt8" readonly="readonly">
   Hello World! </textarea>

j_idt6:j_idt8 is generated by JSF.

h:inputTextarea Tag Attributes

idid for the tag
bindingReference to the component used in a backing bean
renderedA boolean value; false would suppress rendering
styleClassCascading stylesheet (CSS) class name
valuevalue binding
valueChangeListenerA method binding that responds to value changes
converterConverter class name
validatorClass name of a validator attached to the component
requiredA boolean; if true, marks the tag as required
accesskeygives focus to an element
acceptComma-separated list of content types for a form
accept-charsetComma- or space-separated list of character encodings for a form.
altAlternative text for nontextual elements such as images
borderPixel value for an element's border width
charsetCharacter encoding for a linked resource
coordsCoordinates for an element whose shape is a rectangle, circle, or polygon
dirDirection for text. Valid values are ltr (left to right) and rtl (right to left).
disabledDisabled state of an input element or button
hreflangBase language of a resource specified with the href attribute;
langBase language of an element's attributes and text
maxlengthMaximum number of characters for text fields
readonlyRead-only state of an input field
styleInline style information
tabindexNumerical value specifying a tab index
targetThe name of a frame in which a document is opened
titleA title used for accessibility. Browsers typically create tooltips for the title's value
typeType of a link; for example, stylesheet
widthWidth of an element
onblurEvent handler for losing focus
onchangeEvent handler for value changes
onclickEvent handler for Mouse button clicked over the element
ondblclickEvent handler for Mouse button double-clicked
onfocusEvent handler for element received focus
onkeydownEvent handler for Key pressed
onkeypressEvent handler for Key pressed and released
onkeyupEvent handler for Key released
onmousedownEvent handler for Mouse button pressed
onmousemoveEvent handler for mouse moved
onmouseoutEvent handler for mouse left
onmouseoverEvent handler for mouse moved onto
onmouseupEvent handler for mouse button released
onresetEvent handler for form reset
onselectEvent handler for Text selected
immediateProcess validation early in the life cycle


The following code is from welcome.xhtml.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
<html xmlns="http://www.w3.org/1999/xhtml"   
    Address : <h:outputText value="#{userBean.address}" />

The following code is from UserBean.java.

package com.java2s.common;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import java.io.Serializable;

public class UserBean implements Serializable {

  private static final long serialVersionUID = 1L;

  private String address;

  public String getAddress() {
    return address;

  public void setAddress(String address) {
    this.address = address;


The following code is from hello.xhtml.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
<html xmlns="http://www.w3.org/1999/xhtml"   
      <h1>JSF 2 textbox example</h1>
          <td valign="top">Address :</td>
          <td><h:inputTextarea value="#{userBean.address}" cols="30" rows="10" /></td>
        <h:commandButton value="Submit" action="welcome" />

Download Form_TextArea.zip


Copy the generated WAR file from the target folder to Tomcat deployment folder and run Tomcat-Install-folder/bin/startup.bat.

After Tomcat finish starting, type the following URL in the browser address bar.