h:outputFormat tag in JSF

SHARE & COMMENT :

Introduction

The outputFormat tag renders parameterized text and allows you to customize the appearance of this text using CSS styles. Parameterized text is compound text containing placeholder values to be replaced by actual values at rendering time.

also read:

JSP File (index.jsp)

<%@page pageEncoding="UTF-8"%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<html>
    <body>
        <f:view>
            <h:form>
               <h:outputFormat value="Number is {0}.">
                    <f:param value="#{jsfBean.number}" />
                </h:outputFormat>
            </h:form>
        </f:view>
    </body>
</html>

JavaBean (JavaBeatJsfBean.java)

package javabeat.jsf;

/**
 * source : www.javabeat.net
 */
public class JavaBeatJsfBean {
    private String number = "10";;

    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }
    public String submit()
    {
        System.out.println(this.number);
        return "";
    }
}

faces-config.xml

<?xml version='1.0' encoding='UTF-8'?>

<faces-config version="1.2"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">

    <managed-bean>
    <managed-bean-name>jsfBean</managed-bean-name>
    <managed-bean-class>javabeat.jsf.JavaBeatJsfBean</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
</managed-bean>


</faces-config>

view in the browser

jsf-1

Comments

comments

About Krishna Srinivasan

He is Founder and Chief Editor of JavaBeat. He has more than 8+ years of experience on developing Web applications. He writes about Spring, DOJO, JSF, Hibernate and many other emerging technologies in this blog.

Comments

  1. How to pass multiple argument dynamically?

Speak Your Mind

*

Close
Please support the site
By clicking any of these buttons you help our site to get better