• Menu
  • Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

JavaBeat

Java Tutorial Blog

  • Java
    • Java 7
    • Java 8
    • Java EE
    • Servlets
  • Spring Framework
    • Spring Tutorials
    • Spring 4 Tutorials
    • Spring Boot
  • JSF Tutorials
  • Most Popular
    • Binary Search Tree Traversal
    • Spring Batch Tutorial
    • AngularJS + Spring MVC
    • Spring Data JPA Tutorial
    • Packaging and Deploying Node.js
  • About Us
    • Join Us (JBC)
  • Java
    • Java 7
    • Java 8
    • Java EE
    • Servlets
  • Spring Framework
    • Spring Tutorials
    • Spring 4 Tutorials
    • Spring Boot
  • JSF Tutorials
  • Most Popular
    • Binary Search Tree Traversal
    • Spring Batch Tutorial
    • AngularJS + Spring MVC
    • Spring Data JPA Tutorial
    • Packaging and Deploying Node.js
  • About Us
    • Join Us (JBC)

JSF 2 TextArea Example

March 21, 2014 //  by Amr Mohammed//  Leave a Comment

JavaServer Faces (JSF 2) provides a number of user interfaces components that cover the most common requirements, one of the most important component is a <h:inputTextarea/> component. The inputTextarea component renders an HTML AreaText element. If you are looking for the configuration of complete application, please read our JSF 2 Setup Tutorial.

Also Read:

  • JSF 2 Tutorials
  • JSF Tutorials
  • Introduction to JSF

1. Managed Bean

[code lang=”java”] package net.javabeat.jsf;

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

@ManagedBean
@SessionScoped
public class MessageBean {

private String message = "";

public String getMessage() {
return message;
}

public void setMessage(String message) {
this.message = message;
}

public String sendMessage() {
return "inbox";
}

}
[/code]

  • The managed bean (MessageBean) contains a property of type String called message.
  • The managed bean (MessageBean) provides an action for navigating from writing message page into viewing of message page.

2. The Views

message.xhtml

[code lang=”xml”] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<f:view>
<h:form>
<h1><h:outputText value="JavaBeat JSF 2.2 Examples" /></h1>
<h2><h:outputText value="Text Area Example" /></h2>
<h:inputTextarea cols="20" rows="10" value="#{messageBean.message}"></h:inputTextarea>
<h:commandButton value="Send" action="#{messageBean.sendMessage}"></h:commandButton>
</h:form>
</f:view>
</html>
[/code]

inbox.xhtml

[code lang=”xml”] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<f:view>
<h:form>
<h1><h:outputText value="JavaBeat JSF 2.2 Examples" /></h1>
<h2><h:outputText value="Text Area Example" /></h2>
<h:outputLabel value="#{messageBean.message}"/>
</h:form>
</f:view>
</html>
[/code]

3. JSF 2 InputTextArea Demo

The below snapshots show you a complete scenario for using inputTextarea component.

JSF 2 InputTextArea Example 1

JSF 2 InputTextArea Example 2

Category: JSFTag: JSF 2

About Amr Mohammed

Previous Post: « JSF 2 GraphicImage Example
Next Post: HTML5 Number Input Type »

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Follow Us

  • Facebook
  • Pinterest

FEATURED TUTORIALS

np.zeros

A Complete Guide To NumPy Functions in Python For Beginners

What is new in Java 6.0 Collections API?

The Java 6.0 Compiler API

Introductiion to Jakarta Struts

What’s new in Struts 2.0? – Struts 2.0 Framework

JavaBeat

Copyright © by JavaBeat · All rights reserved
Privacy Policy | Contact