Home Jsf JSF view Tag


Share on Google+Share on Google+

JSF view Tag

This tag is used to create the top level view. This acts as a container of all the components that are part of the view of the page.

JSF view Tag


This tag is used to create the top level view. This acts as a container of all the components that are part of the view of the page. Its attribute "locale" is important in the case of making the view internationalized. We can do so by setting the locale attribute to the locale you have to present the view of the page. Suppose we set the locale attribute to "en" or "fr" then the view is presented to the user in English and French respectively. you can also set the locale dynamically and can present the view according to the user.

Code Description :

<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>

<f:view locale="fr">
  <link href="corestyle.css" rel="stylesheet" type="text/css"/>
  <h:inputText id="ab" value="#{MessageBean.b}" required="true"/>
  <h:message for="ab" errorClass="errors"/><br>
  <h:commandButton value="go"/>

Rendered Output : In the above code all component tags have been embedded in the view tag.

In the above tag we have set the locale attribute to "fr" i.e. French locale. In the above code we have used message tag to display the error message if the input field is left blank. So this message is shown in French because of the locale set in the code. The output is shown below.

Html Source Code :

   <link href="corestyle.css" rel="stylesheet" type="text/css"/>
  <form id="_id0" method="post" action="/coretag/pages/view.jsf"   enctype="application/x-www-form-urlencoded">
   <input id="_id0:ab" type="text" name="_id0:ab" value="" /><br>
   <input type="submit" name="_id0:_id2" value="go" />
   <input type="hidden" name="_id0" value="_id0" /></form>

Attributes that this tag uses are given below :

locale : This attribute is used to set the locale of the view. Its default value is that specified in configuration file. It can take static values or EL expressions.


If you enjoyed this post then why not add us on Google+? Add us to your Circles

Liked it!  Share this Tutorial

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: June 18, 2007

Related Tutorials

Ask Questions?    Discuss: JSF view Tag  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
May 29, 2011
value doesn't work

I try to reproduce this example, but received output #{MessageBean.b} What is wrong? Thanks.