Package org.zkoss.web.servlet.xel
Class RequestContexts
- java.lang.Object
-
- org.zkoss.web.servlet.xel.RequestContexts
-
public class RequestContexts extends java.lang.Object
RequestContexts maintains a stack ofRequestContext
to simplify the signatures of the XEL function.It is designed to make the signature of XEL functions (see
ServletFns
) simpler. For example,ServletFns.getCurrentContext()
requires no argument, since it assumes the current context can be retrieved fromgetCurrent()
.Spec Issue:
It is controversial whether the introduction ofRequestContext
andRequestContexts
is worth. However, we have to maintain the backward compatibility of the XEL/EL function signatures.- Since:
- 3.0.0
- Author:
- tomyeh
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
RequestContexts()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static RequestContext
getCurrent()
Returns the current page context if this thread is evaluating a page, or null if not.static void
pop()
Pops the context out and use the previous one as the current context.static void
push(RequestContext jc)
Pushes the context as the current context, such that it will be returned bygetCurrent()
.
-
-
-
Method Detail
-
getCurrent
public static final RequestContext getCurrent()
Returns the current page context if this thread is evaluating a page, or null if not.
-
push
public static final void push(RequestContext jc)
Pushes the context as the current context, such that it will be returned bygetCurrent()
. The reason this method exists is many functions (ServletFns
) counts on it.However, you don't need to invoke this method if you are using DSP.
- If go thru DSP, it is done automatically
(by
Interpreter
Note: you must use try/finally as follows:
RequestContexts.push(jc); try { ... } finally { RequestContexts.pop(); }
- If go thru DSP, it is done automatically
(by
-
pop
public static final void pop()
Pops the context out and use the previous one as the current context.However, you don't need to invoke this method if you are using DSP.
-
-