Easy implementation of JavaServer Faces Web programs using IBM Rational application developer

Source: Internet
Author: User
Tags html page http request locale

The globalization of JavaServer Faces Web programs with IBM Rational application developer easy to implement

Use the JavaServer Widgets Library (JWL) in RAD V7 or later versions

Learn how to use IBM Rational application Developer to implement the globalization of JavaServer Faces Web programs. This article describes the challenges of developing a global marketplace and describes how to use the JavaServer Faces Widget Library (JWL) to address this issue.

Starting with version 7, Ibm®rational®application Developer contains the JavaServer Faces Widget Library (JWL), which is a java™server Faces (JSF)-and is used to quickly open A JavaScript based library that sends a network program.

Jwl,hxclient's JavaScript library, which implements client support for JWL artifacts. It also includes a series of so-called "JSF converters" that help developers analyze and format dates, times, and back-and-forth numbers for specific location patterns, and, more specifically, these tools are JavaScript for Javasimpledateformat and DecimalFormat. Implement. These tools are useful for programs that are designed to support multiple languages because they help you deal with challenges from client-side location-sensitive data entry and output.

This article also explains the globalization challenges associated with multithreading in JavaServer Faces programs and provides a solution. The authors assume that you have a basic knowledge of JSF and JWL.

Basic knowledge of globalization

In a network program, the output language is determined by the Accept-language region of the HTTP request header. Users can specify a language of preference and a place with browser settings.

The JSF framework analyzes the HTTP request header. You can get the value by using the header, as shown in Listing 1.

Listing 1. Get requests for languages and places

Locale locale = FacesContext.getCurrentInstance().getExternalContext().getRequestLocale();

The site value is used to determine the predictions for display.

Use JWL to handle locale-sensitive output and input

After the rapid introduction of globalization, we are now ready to discuss the two challenges facing the global JSF Web program:

Display customer date and time using local format

Show and end Local number formats

How the Hxclient is initialized in the page

As long as you are using the JWL tag in the page, you must make sure that the library is installed on the page and that it is properly initialized. If you set the browser location request to "Ja" (Japanese) and view the source code of the HTML page that was invoked using JWL, you will find the code shown in Listing 2.

Listing 2. Structure of the Web page using JWL

<script type="text/JavaScript" language="JavaScript"
src="/sample/.ibmjsfres/hxclient_core_v3_0_8.js"></script>

<script type="text/JavaScript" language="JavaScript"
src="/sample/.ibmjsfres/hxclient_S_v3_0_8_ja.js?viewLocale=ja">
</script>

<script type="text/JavaScript" language="JavaScript">
   if (hX_5) hX_5.setResourceServer("/sample/.ibmjsfres");
   if(hX_5 && hX_5.setLocale) hX_5.setLocale("ja");
</script>

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.