Package org.zkoss.zk.ui.http
Class I18Ns
- java.lang.Object
-
- org.zkoss.zk.ui.http.I18Ns
-
public class I18Ns extends java.lang.Object
Internationalization utilities.Typical use:
Object old = I18Ns.setup(session, request, response); try { ... } finally { I18Ns.cleanup(old); }
- Author:
- tomyeh
-
-
Constructor Summary
Constructors Constructor Description I18Ns()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
cleanup(javax.servlet.ServletRequest request, java.lang.Object old)
static void
setPreferredTimeZone(javax.servlet.http.HttpSession hsess, java.util.TimeZone timezone)
Sets the preferred timezone for the specified session.static void
setPreferredTimeZone(javax.servlet.ServletContext ctx, java.util.TimeZone timezone)
Sets the preferred timezone for the specified servlet context.static java.lang.Object
setup(javax.servlet.http.HttpSession sess, javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, java.lang.String charset)
Sets up the internationalization attributes, including locale and time zone.static java.lang.Object
setup(Session sess, javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, java.lang.String charset)
Sets up the internationalization attributes, including locale and time zone.
-
-
-
Method Detail
-
setup
public static final java.lang.Object setup(Session sess, javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, java.lang.String charset)
Sets up the internationalization attributes, including locale and time zone.- Parameters:
sess
- the session. It cannot be null.charset
- the response's charset. If null or empty, response.setCharacterEncoding won't be called, i.e., the container's default is used.
-
setup
public static final java.lang.Object setup(javax.servlet.http.HttpSession sess, javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, java.lang.String charset)
Sets up the internationalization attributes, including locale and time zone.This method is used only for requests that don't count on
Session
.- This method first checks if any session attribute called
Attributes.PREFERRED_LOCALE
andAttributes.PREFERRED_TIME_ZONE
are set with the preferred locale and timezone. If so, use it as the default. - Then, it checks if any servlet context attribute called
Attributes.PREFERRED_LOCALE
andAttributes.PREFERRED_TIME_ZONE
are set with the preferred locale and timezone. If so, use it as the default. - Then, it checks if any library properties called
Attributes.PREFERRED_LOCALE
andAttributes.PREFERRED_TIME_ZONE
are set with the preferred locale and timezone. If so, use it as the default. - Otherwise, it depends the setting and location of the browser (by checking the request's header).
- Parameters:
sess
- the HTTP session. It cannot be null.charset
- the response's charset. If null or empty, response.setCharacterEncoding won't be called, i.e., the container's default is used.- Since:
- 3.6.2
- This method first checks if any session attribute called
-
cleanup
public static final void cleanup(javax.servlet.ServletRequest request, java.lang.Object old)
-
setPreferredTimeZone
public static final void setPreferredTimeZone(javax.servlet.http.HttpSession hsess, java.util.TimeZone timezone)
Sets the preferred timezone for the specified session. It is the default timezone for the whole Web session.Default: null (no preferred timezone -- depending on browser's location).
- Parameters:
timezone
- the preferred time zone. If null, it means no preferred timezone- Since:
- 3.6.3
- See Also:
setup(org.zkoss.zk.ui.Session, javax.servlet.ServletRequest, javax.servlet.ServletResponse, java.lang.String)
-
setPreferredTimeZone
public static final void setPreferredTimeZone(javax.servlet.ServletContext ctx, java.util.TimeZone timezone)
Sets the preferred timezone for the specified servlet context. It is the default timezone for the whole Web application.Default: null (no preferred timezone -- depending on browser's location).
- Parameters:
timezone
- the preferred time zone. If null, it means no preferred timezone- Since:
- 3.6.3
- See Also:
setup(org.zkoss.zk.ui.Session, javax.servlet.ServletRequest, javax.servlet.ServletResponse, java.lang.String)
-
-