Package org.zkoss.zk.ui.http
Class I18Ns
- java.lang.Object
-
- org.zkoss.zk.ui.http.I18Ns
-
public class I18Ns extends java.lang.ObjectInternationalization 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 voidcleanup(jakarta.servlet.ServletRequest request, java.lang.Object old)static voidsetPreferredTimeZone(jakarta.servlet.http.HttpSession hsess, java.util.TimeZone timezone)Sets the preferred timezone for the specified session.static voidsetPreferredTimeZone(jakarta.servlet.ServletContext ctx, java.util.TimeZone timezone)Sets the preferred timezone for the specified servlet context.static java.lang.Objectsetup(jakarta.servlet.http.HttpSession sess, jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, java.lang.String charset)Sets up the internationalization attributes, including locale and time zone.static java.lang.Objectsetup(Session sess, jakarta.servlet.ServletRequest request, jakarta.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, jakarta.servlet.ServletRequest request, jakarta.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(jakarta.servlet.http.HttpSession sess, jakarta.servlet.ServletRequest request, jakarta.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_LOCALEandAttributes.PREFERRED_TIME_ZONEare 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_LOCALEandAttributes.PREFERRED_TIME_ZONEare set with the preferred locale and timezone. If so, use it as the default. - Then, it checks if any library properties called
Attributes.PREFERRED_LOCALEandAttributes.PREFERRED_TIME_ZONEare 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(jakarta.servlet.ServletRequest request, java.lang.Object old)
-
setPreferredTimeZone
public static final void setPreferredTimeZone(jakarta.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, jakarta.servlet.ServletRequest, jakarta.servlet.ServletResponse, java.lang.String)
-
setPreferredTimeZone
public static final void setPreferredTimeZone(jakarta.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, jakarta.servlet.ServletRequest, jakarta.servlet.ServletResponse, java.lang.String)
-
-