Package org.zkoss.zk.ui.http
Class I18Ns
java.lang.Object
org.zkoss.zk.ui.http.I18Ns
Internationalization utilities.
Typical use:
Object old = I18Ns.setup(session, request, response);
try {
...
} finally {
I18Ns.cleanup(old);
}
- Author:
- tomyeh
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final voidstatic final voidsetPreferredTimeZone(jakarta.servlet.http.HttpSession hsess, TimeZone timezone) Sets the preferred timezone for the specified session.static final voidsetPreferredTimeZone(jakarta.servlet.ServletContext ctx, TimeZone timezone) Sets the preferred timezone for the specified servlet context.static final Objectsetup(jakarta.servlet.http.HttpSession sess, jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, String charset) Sets up the internationalization attributes, including locale and time zone.static final Objectsetup(Session sess, jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, String charset) Sets up the internationalization attributes, including locale and time zone.
-
Constructor Details
-
I18Ns
public I18Ns()
-
-
Method Details
-
setup
public static final Object setup(Session sess, jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, 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 Object setup(jakarta.servlet.http.HttpSession sess, jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, 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
-
setPreferredTimeZone
public static final void setPreferredTimeZone(jakarta.servlet.http.HttpSession hsess, 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:
-
setPreferredTimeZone
public static final void setPreferredTimeZone(jakarta.servlet.ServletContext ctx, 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:
-