How to use F:loadbundle tags in JSF

Source: Internet
Author: User
Tags config locale resource

The JSF f:loadbundle tag is a label provided by JSF to support JSP localization (multilanguage support) operations.

JSF provides a set of localization support mechanisms, including messages, page displays, and so on. The JSF f:loadbundle tag is a label that provides support for JSP localization (multilanguage Support) operations on the page display.

Using the F:loadbundle tag, you can present a page of different language interfaces for different visitors and simply make your JSF Web application internationalized.

JSF F:loadbundle Usage:

JSF F:loadbundle is very easy to use

1, first, prepare a. properties file for different languages. For example, to support English, Chinese, Japanese, English can be for messages.properties, Chinese for messages_zh.properties, Japanese for messages_ja.properties and so on.

The contents of the file are in the form of:

Message-key=message-value

Username= User name:

The. properties file must be converted to an ASCII form before it is packaged, organized in a directory hierarchy, and placed under the Web-inf directory. For example, the directory class of a resource file can be:

Web-inf\com\test\resource\messages.properties
Web-inf\com\test\resource\messages_zh.properties
Web-inf\com\test\resource\messages_ja.properties

2, and then load the. properties file with the F:loadbundle tag in the JSP, such as loading the resource file with the upper class:

<f:loadbundle basename= "com.test.resource.Messages" var= "msg"/>

Where basename is the location (Com\test\resource) and name (Messages) of the resource file. var is the loaded variable name. JSF can automatically load matching resource files based on the configuration of the user's browser.

Then use H:outputtext to output page content

Or

It's OK.

In addition, JSF support is required for the language required, and the following configuration needs to be Faces-config.xml plus:

<faces-config>
<application>
<locale-config>
<default-locale>en</ default-locale>
<supported-locale>zh</supported-locale>
<supported-locale>ja</ supported-locale>
</locale-config>
</application>
</faces-config>

This configuration tells the JSF framework, the default language configuration, and which language configurations you need to support.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.