Methods Summary |
---|
public int | doEndTag()Creates and initializes a LocaleBean and saves it in the
session scope using the name specified by the "id" property.
LocaleBean bean = (LocaleBean)
pageContext.getAttribute(id, PageContext.SESSION_SCOPE);
if (bean == null) {
bean = new LocaleBean();
pageContext.setAttribute(id, bean, PageContext.SESSION_SCOPE);
}
// Tomcat bug: Only looks for bean in page scope
pageContext.setAttribute(id, bean);
HttpServletRequest request =
(HttpServletRequest) pageContext.getRequest();
HttpServletResponse response =
(HttpServletResponse) pageContext.getResponse();
bean.setRequestLocales(toArray(request.getLocales()));
bean.setSupportedLangs(supportedLangs);
String language = request.getParameter("language");
if (language != null) {
bean.setLanguage(language);
}
String charset = request.getParameter("charset");
if (charset != null) {
bean.setCharset(charset);
bean.setParameters(getParameters(request));
}
bean.setBundleName(bundleName);
response.setHeader("Content-Language", bean.getLanguage());
return EVAL_PAGE;
|
private java.util.Hashtable | getParameters(javax.servlet.http.HttpServletRequest request)Returns a Hashtable with all HTTP parameters from an
HttpServetRequest. The key in the Hashtable is the
parameter name and the value is a String[].
Hashtable parameters = new Hashtable();
Enumeration names = request.getParameterNames();
while (names.hasMoreElements()) {
String name = (String) names.nextElement();
parameters.put(name, request.getParameterValues(name));
}
return parameters;
|
public void | release()Releases all instance variables.
id = null;
bundleName = null;
supportedLangs = null;
super.release();
|
public void | setBundleName(java.lang.String bundleName)Sets the bundleName property, i.e. the base name for the
ResourceBundle used for localized text.
this.bundleName = bundleName;
|
public void | setId(java.lang.String id)Sets the id property, i.e. the name to use for the
LocaleBean in the session scope.
this.id = id;
|
public void | setSupportedLangs(java.lang.String supportedLangs)Sets the supportedLangs property, i.e. a comma separated
list of language/country codes.
this.supportedLangs = supportedLangs;
|
private java.util.Locale[] | toArray(java.util.Enumeration locales)Converts an Enumeration of Locale objects to a
Locale array.
Vector v = new Vector();
while (locales.hasMoreElements()) {
v.addElement(locales.nextElement());
}
Locale[] localeArr = new Locale[v.size()];
v.copyInto(localeArr);
return localeArr;
|