Package org.zkoss.web.fn
Class ServletFns
- java.lang.Object
-
- org.zkoss.web.fn.ServletFns
-
public class ServletFns extends java.lang.ObjectProviding servlet relevant functions for EL.- Author:
- tomyeh
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedServletFns()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static java.lang.StringencodeThemeURL(java.lang.String s)Encodes a URL with theme key injected.static java.lang.StringencodeURL(java.lang.String uri)Encodes a URL.static RequestContextgetCurrentContext()Returns the current EL context.static java.io.WritergetCurrentOut()Returns the current output.static javax.servlet.ServletRequestgetCurrentRequest()Returns the current servlet request, or null if not available.static javax.servlet.ServletResponsegetCurrentResponse()Returns the current servlet response, or null if not available.static javax.servlet.ServletContextgetCurrentServletContext()Returns the current servlet context, or null if not available.static booleanisBrowser(java.lang.String type)Deprecated.As of release 6.0.0, replaced withServlets.getBrowser(javax.servlet.ServletRequest, java.lang.String).static booleanisExplorer()Deprecated.As of release 6.0.0, replaced withServlets.getBrowser(javax.servlet.ServletRequest, java.lang.String).static booleanisExplorer7()Deprecated.As of release 6.0.0, replaced withServlets.getBrowser(javax.servlet.ServletRequest, java.lang.String).static booleanisGecko()Deprecated.As of release 6.0.0, replaced withServlets.getBrowser(javax.servlet.ServletRequest, java.lang.String).static booleanisGecko3()Deprecated.As of release 6.0.0, replaced withServlets.getBrowser(javax.servlet.ServletRequest, java.lang.String).static booleanisOpera()Deprecated.As of release 6.0.0, replaced withServlets.getBrowser(javax.servlet.ServletRequest, java.lang.String).static booleanisSafari()Deprecated.As of release 6.0.0, replaced withServlets.getBrowser(javax.servlet.ServletRequest, java.lang.String).static voidrender(ActionContext ac)Renders the DSP fragment from EL.static java.lang.StringresolveThemeURL(java.lang.String url)Resolves a URL to point to resource served by the current theme.
-
-
-
Method Detail
-
encodeURL
public static java.lang.String encodeURL(java.lang.String uri) throws javax.servlet.ServletExceptionEncodes a URL.If an URI contains "*", it will be replaced with a proper Locale. For example, if the current Locale is zh_TW and the resource is named "ab*.cd", then it searches "ab_zh_TW.cd", "ab_zh.cd" and then "ab.cd", until any of them is found.
Note: "*" must be right before ".", or the last character. For example, "ab*.cd" and "ab*" are both correct, while "ab*cd" and "ab*\/cd" are ignored.
If an URI contains two "*", the first "*" will be replaced with a browser code and the second with a proper locale. The browser code depends on what browser the user are used to visit the web site. Currently, the code for Internet Explorer is "ie", Safari is "saf", Opera is "opr" and all others are "moz". Thus, in the above example, if the resource is named "ab**.cd" and Firefox is used, then it searches "abmoz_zh_TW.cd", "abmoz_zh.cd" and then "abmoz.cd", until any of them is found.
- Throws:
javax.servlet.ServletException
-
encodeThemeURL
public static final java.lang.String encodeThemeURL(java.lang.String s) throws javax.servlet.ServletExceptionEncodes a URL with theme key injected.- Parameters:
s- the string to encode- Returns:
- the encoded string or null if s is null
- Throws:
java.io.UnsupportedEncodingExceptionjavax.servlet.ServletException- Since:
- 6.0.0
-
resolveThemeURL
public static final java.lang.String resolveThemeURL(java.lang.String url)
Resolves a URL to point to resource served by the current theme.- Parameters:
url- the default theme url to resolve- Returns:
- the resolved url or null if url is null
- Since:
- 6.5.2
-
isBrowser
public static boolean isBrowser(java.lang.String type)
Deprecated.As of release 6.0.0, replaced withServlets.getBrowser(javax.servlet.ServletRequest, java.lang.String).Returns whether the current request is from a browser of the specified type.- Parameters:
type- the type of the browser. The syntax:<browser-name>[<version-number>][-].
For example, ie9, ios and ie6-. And,ie9means Internet Explorer 9 and later, whileie6-means Internet Explorer 6 (not prior, nor later).- Since:
- 3.5.1
-
isExplorer
public static boolean isExplorer()
Deprecated.As of release 6.0.0, replaced withServlets.getBrowser(javax.servlet.ServletRequest, java.lang.String).Returns whether the browser of the current request is Explorer.
-
isExplorer7
public static boolean isExplorer7()
Deprecated.As of release 6.0.0, replaced withServlets.getBrowser(javax.servlet.ServletRequest, java.lang.String).Returns whether the browser of the current request is Explorer 7 or later.
-
isGecko
public static boolean isGecko()
Deprecated.As of release 6.0.0, replaced withServlets.getBrowser(javax.servlet.ServletRequest, java.lang.String).Returns whether the browser of the current request is Gecko based, such as Mozilla, Firefox and Camino.
-
isGecko3
public static boolean isGecko3()
Deprecated.As of release 6.0.0, replaced withServlets.getBrowser(javax.servlet.ServletRequest, java.lang.String).Returns whether the browser is Gecko 3 based, such as Firefox 3.- Since:
- 3.5.0
-
isSafari
public static boolean isSafari()
Deprecated.As of release 6.0.0, replaced withServlets.getBrowser(javax.servlet.ServletRequest, java.lang.String).Returns whether the browser of the current request is Safari.
-
isOpera
public static boolean isOpera()
Deprecated.As of release 6.0.0, replaced withServlets.getBrowser(javax.servlet.ServletRequest, java.lang.String).Returns whether the browser of the current request is Opera.
-
getCurrentContext
public static RequestContext getCurrentContext()
Returns the current EL context.
-
getCurrentOut
public static java.io.Writer getCurrentOut() throws java.io.IOExceptionReturns the current output.- Throws:
java.io.IOException
-
getCurrentServletContext
public static javax.servlet.ServletContext getCurrentServletContext()
Returns the current servlet context, or null if not available.
-
getCurrentRequest
public static javax.servlet.ServletRequest getCurrentRequest()
Returns the current servlet request, or null if not available.
-
getCurrentResponse
public static javax.servlet.ServletResponse getCurrentResponse()
Returns the current servlet response, or null if not available.
-
render
public static void render(ActionContext ac) throws DspException, java.io.IOException
Renders the DSP fragment from EL.- Parameters:
ac- the action context; never null.- Throws:
DspExceptionjava.io.IOException
-
-