Webcam Chat QuickBooks Advice international calling cards international phone cards
JavaBeat Java Books Certifications Certifications Kits Articles Tutorials Tips QNA Book Store Interview Questions SCJP 1.5 SCJP 1.6 SCWCD 5.0 SCBCD 5.0 SCEA SCJA Feeds

f:view

Topic :
Feedback Request New QnA Print Email

f:view

The View tag is the container for all JavaServer Faces component tags used on a page. You can wrap the root element of the structured markup language used in your document with this tag to ensure that all child tags are part of the same view.

This tag is useful for internationalization (I18N) purposes. It provides you with several options for presenting your user with localized views of your application. By default the JSF framework will attempt to select the best view for your user based on the Accept-Language header sent to the server from the user's browser as part of the HTTP request for your page.

If the locale requested by the user is not supported by your application, the JSF framework will use the default locale specified in your Faces configuration file. If you have not specified a default locale, JSF will use the default locale for the Java Virtual Machine serving your application.

If your application supports the locale requested by the user, JSF will set that locale for the view and will display the messages for that locale defined in the locale's message bundle.

You can also specify the locale for which the view is to be rendered by explicitly setting the locale attribute of the view tag. This allows you to design localized versions of each page, including images and styles, for each locale you wish to support.

Another option is to obtain the locale dynamically through user interaction. This information could later be stored in a cookie and/or a database to identify which locale is preferred by your user. The locale attribute accepts a value-binding expression that could resolve to the desired locale.

Example:

welcome_en.jsp (English)
<f:view locale="en">
<f:loadBundle basename="com.mycompany.MessageBundle" var="bundle" />
<h:outputText value="#{bundle.welcomeMessage}" />
</f:view>
welcome_fr.jsp (French)
<f:view locale="fr">
<f:loadBundle basename="com.mycompany.MessageBundle" var="bundle" />
<h:outputText value="#{bundle.welcomeMessage}" />
</f:view>

HTML Output

welcome_en.jsp (English)
Welcome to our site!
welcome_fr.jsp (French)
Bienvenue à notre site!

Tag Attributes

localeString
The locale attribute sets the locale to use for localizing this page. Literal values and value-binding expressions must evaluate to a java.util.Locale or to a String that can be converted to a Locale.

Topic :
Feedback Request New QnA Print Email

All api java java 6.0 java 7.0 jdbc jsp servlet ejb jndi jms ejb 3.0 j2ee jee 5.0 jee 6.0 jsf struts spring Hibernate ajax JBoss Seam netbeans eclipse ant xml maven dojo junit javafx j2me log4j ESB JBoss Apache Quartz scjp mysql oracle gwt openjpa jmx yui google-guice android JBoss scwcd 5.0 scjp 1.5 scjp 1.6 scja scbcd 5.0

JavaBeat Website (2004-2011), India
javabeat | advertise | about us | contact | useful resources
Copyright (2004 - 2011), JavaBeat


Technology Blogs
Technology blogs Technology Blogs
blog log