JavaBeat
calling cards | international calling cards | phone card
Search JavaBeat

JAVABEAT
home
tips
articles
QnA
forums
TIPS TOPICS
Java Basics
JSP
JSF
Spring
Hibernate
EJB 3.0
JMS
Log4j
Ant
Eclipse
Netbeans
ARCHIVE
2008 | 08 07 06 05 04 03 02 01
2007 | 12 11 10 09 08
Enter email address:

Latest JavaBeat Tips Delivered
OUR NETWORK
javabeat
planetoss

How to use Resource Bundle in JSF?

You may be interested...
Life Cycle of JSF Components
JSF Best Practices
New Features in JSF 2.0
Implement Internationalization and Localization in JSF
Creating simple toolbar using RichFaces tag library
Have a look at this...
JSP | JSF | Spring | Hibernate
EJB 3.0 | JMS | Log4j | Eclipse | Netbeans
Free Subscription
Enter email address:

Latest JavaBeat Tips Delivered
Author : JavaBeat
Date : Sat Apr 12th, 2008
Topic : jsf
Add to: Digg Add to: Del.icio.us Add to: Reddit Add to: StumbleUpon Add to: Slashdot Add to: Yahoo Add to: Google Add to: Blinklist Add to: Technorati Information

  • Topic : Java Server Faces (JSF)

  • Environment : J2EE 5.0, MyFaces 1.1.5

  • Discuss Here

Resource Bundle in JSF

This section explain how to use message resources in Java Server Faces (JSF). Resource Bundles are very important when comes to internationalization.JSF framework provides simple way to configure and use th message resources in your application. Follow the steps to configure resource-bundle:

  • Step :1
  • Create a properties file. In our example we have created ApplicationResources.properties
  • Step :2
  • Add message-bundle element in the faces-config.xml. for more details see the complete program in the example section.
  • Step :3
  • Load the bundle using f:loadBundle tag in jsp file.
  • Step :4
  • Use the "msg" varible (which is defined while loading the message bundle) in the tags to get message resources.

applicationResources.jsp

	

<!--
   Source : www.javabeat.net
-->
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<f:loadBundle basename="net.javabeat.myfaces.resource.ApplicationResources" var="msg"/>
<html>
    <body>
        <f:view>
            <h:form id="resources">
                <h:outputFormat value="#{msg.testMessage1}">
                    <f:param value="Apple"/>
                    <f:param value="Google"/>
                </h:outputFormat>
                <h:outputLabel value="#{msg.testMessage2}"/>
            </h:form>
        </f:view>
    </body>
</html>
	

faces-config.xml

	
    <application>        
        <locale-config>            
            <default-locale>en</default-locale>            
        </locale-config>
        <message-bundle>            
            net.javabeat.myfaces.resource.ApplicationResources
        </message-bundle>
    </application>
	

ApplicationResources.properties

	
# Sample ResourceBundle properties file
testMessage1={0} and {1} is most innovative companies in IT
testMessage2=Google - The internet God
	


Favorites
AffiliatedAds.com
Buy movies
Access Control
Busby seo challenge contest
Sohbet
Chat
Webmaster Hosting Forum
Java Jobs
MyVideoLib
India News
Internet Advances
Sohbet
chat
Latest QnA
SCJD Tips
When we start a thread by applying start() method on it ,how does it knows that to execute run()method?
About Wrapper class in Java
How to configure weblogic 7.0 in MyEclipse?
Static Block and Static Initializer in Java

JavaBeat Website (2004-2008), India
javabeat | about us | planetoss
Copyright (2004 - 2008), JavaBeat