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.

Ads

Tutorials   
JSF Tutorials: Easy steps to learn JSF Java Server Faces (JSF) Tutorials What is JSF Mojarra? JSF Life Cycle JSF Examples JSF Tutorial For Beginners Roseindia JSF Tutorial JSF core Tag Reference JSF internationalization example Tomahawk selectOneCountry tag RCFaces About Hibernate, Spring and JSF Integration Tutorial Creating Login Page In JSF using NetBeans JSF Hello World Declaring the Bean class in the faces-config.xml file Creating a Web Application with the JSF Framework Binding the Form Elements With the Bean Properties Adding Navigation in JSF Application Binding Component Instance to a Bean Property Tomahawk validateEqual tag Tomahawk validateEmail tag Tomahawk validateCreditCard tag Tomahawk selectOneListbox tag Tomahawk selectManyListbox tag Tomahawk selectManyCheckbox tag Tomahawk selectBooleanCheckbox tag Tomahawk saveState tag Tomahawk popup tag Tomahawk inputCalendar tag Tomahawk htmlTag tag Tomahawk graphicImage tag Tomahawk documentHead tag Tomahawk documentBody tag Tomahawk document tag Tomahawk column tag DataBase Connectivity with MySql in Visual Web JSF Application Using Net Beans IDE Retrieve Image in JSF From MySQL Table Using NetBeans IDE JSF Training Java Sever Faces 1.2 - JSF 1.2 Display Data from Database in JSF Application Business Objects of Business Logic tier Setup MySQL Database Working with Database through JDBC Working with JavaScript & CSS Referencing a Localized Message Referencing Resource Bundle from a Page Binding Component Value to an Implicit Object Phase Listener Value Change Event Listener Action Event Listener
Ads

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">
 <html>
  <head>
  <link href="corestyle.css" rel="stylesheet" type="text/css"/>
  </head>
  <body>
   <h:form> 
  <h:inputText id="ab" value="#{MessageBean.b}" required="true"/>
  <h:message for="ab" errorClass="errors"/><br>
  <h:commandButton value="go"/>
   </h:form>
  </body>
 </html>
</f:view>

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 :

<html>
   <head>
   <link href="corestyle.css" rel="stylesheet" type="text/css"/>
   </head>
   <body>
  <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>
   </body>
</html>

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.

Advertisements

Ads
Share on Google+Share on Google+

JSF view Tag

Posted on: June 18, 2007 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

Ads
 

Discuss: JSF view Tag  

Post your Comment


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

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

Ads

 

Ads