KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nextime > ion > frontoffice > servlet > CommonThings


1 package org.nextime.ion.frontoffice.servlet;
2
3 import java.util.Iterator JavaDoc;
4 import java.util.ResourceBundle JavaDoc;
5 import javax.servlet.http.HttpServletRequest JavaDoc;
6 import javax.servlet.http.HttpServletResponse JavaDoc;
7
8 import org.nextime.ion.framework.locale.Locale;
9 import org.nextime.ion.framework.locale.LocaleList;
10
11 /**
12  * @author gbort
13  */

14 public class CommonThings {
15
16     public static void common(
17         HttpServletRequest JavaDoc request,
18         HttpServletResponse JavaDoc response) {
19             
20         // locale setting
21
String JavaDoc currentLocale = (String JavaDoc)request.getSession().getAttribute("currentLocale");
22         if( currentLocale == null ) {
23             currentLocale = ((Locale)LocaleList.getInstance().getLocales().iterator().next()).getLocale();
24             // check if fallbacklocale is supported
25
Iterator JavaDoc it = LocaleList.getInstance().getLocales().iterator();
26         while (it.hasNext()) {
27             if (((Locale) it.next()).getLocale().equals(request.getLocale().getLanguage())) {
28                 currentLocale = request.getLocale().getLanguage();
29             }
30         }
31             
32             request.getSession().setAttribute("currentLocale",currentLocale);
33         }
34         //request.getSession().setAttribute("javax.servlet.jsp.jstl.fmt.locale", currentLocale);
35

36         // set the localized property of section name
37
request.setAttribute("sectionNameProperty", "name_"+currentLocale);
38     }
39
40 }
41
Popular Tags