Frameworks| Hibernate| Struts| JSF| JavaFX| Ajax| Spring| DOJO| JDO| iBatis| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Referencing Resource Bundle from a Page 
 

JSF provides a good way to implement internationalization using Resource Bundle. Resource Bundle is a file that contains the information as key and value pair (In key=value format).

 

Referencing Resource Bundle from a Page

                          

JSF provides a good way to implement internationalization using Resource Bundle. Resource Bundle is a file that contains the information as key and value pair (In key=value format). You can store label, button text, messages, dates and times, numbers, currencies etc according to the specific locale.

Steps to Create Resource Bundle:

1. Create a file "Messages.properties" under the classes folder of tomcat.

2. Write some key, value pair values in this file.

Messages.properties

 

# Sample ResourceBundle properties file
inputname_header=Roseindia
name_text=Enter Your Name:
greeting_text=Welcome In Roseindia
button_text=Submit


3. Write the a line of code to get the file in the page.

<f:loadBundle basename="roseindia.Messages" var="message"/>

where "basename" attribute is assigned the string value representing the path of bundle file under the classes folder and "var" attribute is assigned a value which will be used further in the whole page to reference the key in the properties file.

For example:

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

<f:loadBundle basename="roseindia.Messages" var="message"/>

<f:view>
<html>
<head><title></title></head>

<body>
<h:form>
<h1><h:outputText value="#{message.inputname_header}"/></h1>
<h:outputText value="#{message.name_text}"/>
<h:inputText value="#{ResourceBean.personName}" />
<h:commandButton action="welcome" value="#{message.button_text}" />
</h:form>
</body>
</html>
</f:view>

Download code for all examples

                          

» View all related tutorials
Related Tags: c file ide orm text date jsf form internationalization time air button io dates format label numbers vi locale key

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.