|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.zkoss.zk.ui.impl.AbstractExecution
org.zkoss.zk.ui.http.ExecutionImpl
public class ExecutionImpl
An Execution
implementation for HTTP request
and response.
Field Summary |
---|
Fields inherited from interface org.zkoss.zk.ui.Execution |
---|
APPEND_PARAM, IGNORE_PARAM, OVERWRITE_URI, PASS_THRU_ATTR |
Constructor Summary | |
---|---|
ExecutionImpl(javax.servlet.ServletContext ctx,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
Desktop desktop,
Page creating)
Constructs an execution for HTTP request. |
Method Summary | |
---|---|
void |
addDateHeader(java.lang.String name,
long value)
Deprecated. It is suggested to use Execution.getNativeResponse()
instead. |
void |
addHeader(java.lang.String name,
java.lang.String value)
Deprecated. As of release 3.6.3, replaced with Execution.addResponseHeader(java.lang.String, java.lang.String) . |
void |
addResponseHeader(java.lang.String name,
java.lang.String value)
Adds a response header with the give name and value. |
boolean |
addScopeListener(ScopeListener listener)
Adds a listener to listen whether this scope is changed. |
boolean |
containsResponseHeader(java.lang.String name)
Returns whether the named response header has already been set. |
java.lang.String |
encodeURL(java.lang.String uri)
Encodes an URL. |
java.lang.Object |
evaluate(Component comp,
java.lang.String expr,
java.lang.Class expectedType)
Evluates the specified expression with ${link #getVariableResolver} and Page.getFunctionMapper() of the page of the specified
component. |
java.lang.Object |
evaluate(Page page,
java.lang.String expr,
java.lang.Class expectedType)
Evluates the specified expression with ${link #getVariableResolver} and Page.getFunctionMapper() of the specified
page. |
void |
forward(java.lang.String page)
A shortcut of forward(null, page, null, 0). |
void |
forward(java.io.Writer out,
java.lang.String page,
java.util.Map params,
int mode)
Forwards to another page. |
java.lang.Object |
getAttribute(java.lang.String name)
Returns the value of the specified request attribute. |
java.util.Map |
getAttributes()
Returns a map of request attributes associated with this session. |
java.lang.String |
getContextPath()
Returns the portion of the request URI that indicates the context of the current execution. |
Evaluator |
getEvaluator(Component comp,
java.lang.Class expfcls)
Returns the evaluator of the current execution. |
Evaluator |
getEvaluator(Page page,
java.lang.Class expfcls)
Returns the evaluator (never null). |
java.lang.String |
getHeader(java.lang.String name)
Returns the value of the specified header as a String ,
or null if not found. |
java.util.Iterator |
getHeaderNames()
Returns all header names this request contains. |
java.util.Iterator |
getHeaders(java.lang.String name)
Returns all the values of the specified header as a Iterator
of String objects. |
java.lang.String |
getLocalAddr()
Returns the Internet Protocol (IP) address of the interface on which the request was received. |
java.lang.String |
getLocalName()
Returns the host name of the Internet Protocol (IP) interface on which the request was received. |
int |
getLocalPort()
Returns the Internet Protocol (IP) port number of the interface on which the request was received. |
java.lang.Object |
getNativeRequest()
Returns the native request, or null if not available. |
java.lang.Object |
getNativeResponse()
Returns the native response, or null if not available. |
PageDefinition |
getPageDefinition(java.lang.String uri)
Returns the page definition from the page file specified by an URI. |
PageDefinition |
getPageDefinitionDirectly(Document content,
java.lang.String ext)
Converts the specified page content, in DOM, to a page definition. |
PageDefinition |
getPageDefinitionDirectly(java.io.Reader reader,
java.lang.String ext)
Reads the raw content from a reader and converts it into a page definition. |
PageDefinition |
getPageDefinitionDirectly(java.lang.String content,
java.lang.String ext)
Converts the specified page content to a page definition. |
java.lang.String |
getParameter(java.lang.String name)
Returns the value of a request parameter as a String, or null if the parameter does not exist |
java.util.Map |
getParameterMap()
Returns a Map of the parameters of this request. |
java.lang.String[] |
getParameterValues(java.lang.String name)
Returns an array of String objects containing all of the values the given request parameter has, or null if the parameter does not exist. |
java.lang.String |
getRemoteAddr()
Returns the Internet Protocol (IP) address of the client or last proxy that sent the request. |
java.lang.String |
getRemoteHost()
Returns the fully qualified name of the client or the last proxy that sent the request. |
java.lang.String |
getRemoteUser()
Returns the login of the user making this request, if the user has been authenticated, or null if the user has not been authenticated. |
java.lang.String |
getScheme()
Returns the name of the scheme used to make this request, for example, http, https, or ftp. |
java.lang.String |
getServerName()
Returns the host name of the server to which the request was sent. |
int |
getServerPort()
Returns the port number to which the request was sent. |
java.lang.String |
getUserAgent()
Returns the user-agent header, which indicates what the client is, or an empty string if not available. |
java.security.Principal |
getUserPrincipal()
Returns a java.security.Principal object containing the name of the current authenticated user. |
VariableResolver |
getVariableResolver()
Returns the variable resolver for this execution, or null if not available. |
boolean |
hasAttribute(java.lang.String name)
Returns if a custom attribute is associated with this object (scope). |
void |
include(java.lang.String page)
A shortcut of include(null, page, null, 0). |
void |
include(java.io.Writer out,
java.lang.String page,
java.util.Map params,
int mode)
Includes a page. |
boolean |
isBrowser()
Returns whether the client is a browser. |
boolean |
isBrowser(java.lang.String type)
Returns whether it is a browser of the specified type. |
boolean |
isExplorer()
Returns whether the client is Internet Explorer. |
boolean |
isExplorer7()
Returns whether the client is Internet Explorer 7 or later. |
boolean |
isForwarded()
Returns whether the execution is forwarded from other pages. |
boolean |
isGecko()
Returns whether the client is Gecko based, such as Mozilla, Firefox and Camino. |
boolean |
isGecko3()
Returns whether the browser is Gecko 3 based, such as Firefox 3. |
boolean |
isHilDevice()
Returns whether the client is a mobile device supporting HIL (Handset Interactive Language). |
boolean |
isIncluded()
Returns whether this execution is included by some other pages. |
boolean |
isMilDevice()
Deprecated. As of release 5.0.0, MIL is no longer supported. |
boolean |
isOpera()
Returns whether the client is Opera. |
boolean |
isRobot()
Returns whether the client is a robot (such as Web crawlers). |
boolean |
isSafari()
Returns whether the client is Safari. |
boolean |
isUserInRole(java.lang.String role)
Returns a boolean indicating whether the authenticated user is included in the specified logical "role". |
boolean |
isVoided()
Returns whether the execution is voided. |
java.lang.String |
locate(java.lang.String path)
Locates a page based on the current Locale. |
void |
onActivate()
Called when this execution is about to become the current execution Executions.getCurrent() . |
void |
onDeactivate()
Called when this execution is about to become a non-current execution. |
java.lang.Object |
removeAttribute(java.lang.String name)
Removes the specified request attribute. |
boolean |
removeScopeListener(ScopeListener listener)
Removes a change listener from this scope. |
java.lang.Object |
setAttribute(java.lang.String name,
java.lang.Object value)
Sets the value of the specified request attribute. |
void |
setContentType(java.lang.String contentType)
Sets the content type. |
void |
setDateHeader(java.lang.String name,
long value)
Deprecated. It is suggested to use Execution.getNativeResponse()
instead. |
void |
setHeader(java.lang.String name,
java.lang.String value)
Deprecated. As of release 3.6.3, replaced with Execution.setResponseHeader(java.lang.String, java.lang.String) . |
void |
setResponseHeader(java.lang.String name,
java.lang.String value)
Sets a response header with the give name and value. |
void |
setVoided(boolean voided)
Sets whether the execution is voided. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ExecutionImpl(javax.servlet.ServletContext ctx, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Desktop desktop, Page creating)
creating
- which page is being creating for this execution, or
null if none is being created.
AbstractExecution.isAsyncUpdate(org.zkoss.zk.ui.Page)
returns based on this.Method Detail |
---|
public void onActivate()
ExecutionCtrl
Executions.getCurrent()
.
Note: an execution might spread over several threads, so this method might be called several times to activate the states in each thread. Also, an execution might be activated before another is deactivate. For example, when a component includes another page, the second exec is activated to render the included page.
It is used as callback notification.
Note: don't throw any exception in this method.
onActivate
in interface ExecutionCtrl
onActivate
in class AbstractExecution
public void onDeactivate()
ExecutionCtrl
It is used as callback notification.
Note: don't throw any exception in this method.
onDeactivate
in interface ExecutionCtrl
onDeactivate
in class AbstractExecution
ExecutionCtrl.onActivate()
public java.lang.String[] getParameterValues(java.lang.String name)
Execution
public java.lang.String getParameter(java.lang.String name)
Execution
public java.util.Map getParameterMap()
Execution
public VariableResolver getVariableResolver()
Execution
Note: the resolver is similar to PageContext's if this execution is caused by a HTTP request.
Execution.evaluate(Component,String,Class)
public Evaluator getEvaluator(Page page, java.lang.Class expfcls)
Execution
Expression
or used with ExValue
.
for performance improvement.
page
- the page that this evaluator is associated.
If null, the current page and then the first page is assumed.expfcls
- the implementation of ExpressionFactory
,
or null to use the default (Configuration.getExpressionFactoryClass()
.public Evaluator getEvaluator(Component comp, java.lang.Class expfcls)
Execution
comp
- the component to retrieve the page for the evaluatorexpfcls
- the implementation of ExpressionFactory
,
or null to use the default (Configuration.getExpressionFactoryClass()
.public java.lang.Object evaluate(Component comp, java.lang.String expr, java.lang.Class expectedType)
Execution
Page.getFunctionMapper()
of the page of the specified
component.
The function mapper is retrieved from component's page's function
mapper (Page.getFunctionMapper()
).
If null, the current page, if any, is used to retrieve
the mapper.
For better performance, you can use the instance returned by
Execution.getEvaluator(org.zkoss.zk.ui.Page, java.lang.Class)
to parse and cached the parsed expression.
ExValue
is a utility class to simply
the task.
comp
- used as the self variable and to retrieve the function
mapper. Ignored if null.Execution.getVariableResolver()
,
Execution.getEvaluator(org.zkoss.zk.ui.Page, java.lang.Class)
public java.lang.Object evaluate(Page page, java.lang.String expr, java.lang.Class expectedType)
Execution
Page.getFunctionMapper()
of the specified
page.
The function mapper is retrieved from component's page's function
mapper (Page.getFunctionMapper()
).
If null, the current page, if any, is used to retrieve
the mapper.
For better performance, you can use the instance returned by
Execution.getEvaluator(org.zkoss.zk.ui.Page, java.lang.Class)
to parse and cached the parsed expression.
ExValue
is a utility class to simply
the task.
page
- used as the self variable and to retrieve the function
mapper. Ignored if null.Execution.getVariableResolver()
,
Execution.getEvaluator(org.zkoss.zk.ui.Page, java.lang.Class)
public void include(java.io.Writer out, java.lang.String page, java.util.Map params, int mode) throws java.io.IOException
Execution
out
- the output to write. If null, the response's default
writer is used.page
- the page's uri; null to denote the same requestmode
- one of Execution.OVERWRITE_URI
, Execution.IGNORE_PARAM
,
Execution.APPEND_PARAM
and Execution.PASS_THRU_ATTR
.
It defines how to handle if both uri and params contains
the same parameter.
mode is used only if both uri contains query string and params is
not empty.
java.io.IOException
public void include(java.lang.String page) throws java.io.IOException
Execution
java.io.IOException
public void forward(java.io.Writer out, java.lang.String page, java.util.Map params, int mode) throws java.io.IOException
Execution
Note: this method can be called only when loading a page.
Use Execution.sendRedirect(String)
instead if you want to change
to another desktop when processing a request from the client.
out
- the output to write. If null, the response's default
writer is used.page
- the page's uri; null to denote the same requestmode
- one of Execution.OVERWRITE_URI
, Execution.IGNORE_PARAM
,
Execution.APPEND_PARAM
and Execution.PASS_THRU_ATTR
.
It defines how to handle if both uri and params contains
the same parameter.
mode is used only if both uri contains query string and params is
not empty.
java.io.IOException
public void forward(java.lang.String page) throws java.io.IOException
Execution
java.io.IOException
public boolean isIncluded()
Execution
public boolean isForwarded()
Execution
public java.lang.String locate(java.lang.String path)
Execution
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.
Note: it assumes the path as name_lang_cn_var.ext where ".ext" is optional. Example, my_zh_tw.html.jsp.
If an URI starting with "~./", it assumes the resource is from the class path.
path
- the page path excluding servlet name. It is OK to have
the query string. It might contain "*" for current browser code and Locale.
path
, otherwisepublic boolean isVoided()
Execution
The common cause of being voided is the invocation of
Execution.forward(java.io.Writer, java.lang.String, java.util.Map, int)
.
public void setVoided(boolean voided)
Execution
If you invoke Execution.forward(java.io.Writer, java.lang.String, java.util.Map, int)
, this method is called automatically
with true. Thus, you rarely need to invoke this method, unless
you forward to other servlet by use javax.servlet.RequestDispatcher
directly.
public java.lang.String encodeURL(java.lang.String uri)
Execution
It resolves "*" contained in URI, if any, to the proper Locale,
and the browser code.
Refer to Servlets.locate(ServletContext, ServletRequest, String, Locator)
for details.
public java.security.Principal getUserPrincipal()
Execution
public boolean isUserInRole(java.lang.String role)
Execution
role
- a String specifying the name of the rolepublic java.lang.String getRemoteUser()
Execution
public java.lang.String getRemoteHost()
Execution
public java.lang.String getRemoteAddr()
Execution
public java.lang.String getServerName()
Execution
Execution.getLocalName()
public int getServerPort()
Execution
Execution.getLocalPort()
public java.lang.String getLocalName()
Execution
Note: it is the host name defined in the server. To retrieve the name
in URL, use Execution.getServerName()
.
Execution.getServerName()
public java.lang.String getLocalAddr()
Execution
public int getLocalPort()
Execution
Execution.getServerPort()
public java.lang.String getContextPath()
Execution
If the client is not using HTTP to access, this method return "";
Page.getRequestPath()
public java.lang.String getScheme()
Execution
public PageDefinition getPageDefinition(java.lang.String uri)
Execution
Implemetation Notes: this method must invoke
UiFactory.getPageDefinition(org.zkoss.zk.ui.sys.RequestInfo, String)
uri
- the URI of the page file.Execution.getPageDefinitionDirectly(String, String)
,
Execution.getPageDefinitionDirectly(Document, String)
,
Execution.getPageDefinitionDirectly(Reader, String)
public PageDefinition getPageDefinitionDirectly(java.lang.String content, java.lang.String ext)
Execution
Implemetation Notes: this method must invoke
UiFactory.getPageDefinitionDirectly(org.zkoss.zk.ui.sys.RequestInfo, String, String)
content
- the raw content of the page. It must be in ZUML.ext
- the default extension if the content doesn't specify
an language. In other words, if
the content doesn't specify an language, LanguageDefinition.getByExtension(java.lang.String)
is called.
If extension is null and the content doesn't specify a language,
the language called "xul/html" is assumed.Execution.getPageDefinitionDirectly(Document, String)
,
Execution.getPageDefinitionDirectly(Reader, String)
,
Execution.getPageDefinition(java.lang.String)
public PageDefinition getPageDefinitionDirectly(Document content, java.lang.String ext)
Execution
content
- the raw content of the page in DOM.ext
- the default extension if the content doesn't specify
an language. In other words, if
the content doesn't specify an language, LanguageDefinition.getByExtension(java.lang.String)
is called.
If extension is null and the content doesn't specify a language,
the language called "xul/html" is assumed.Execution.getPageDefinitionDirectly(String, String)
,
Execution.getPageDefinitionDirectly(Reader, String)
,
Execution.getPageDefinition(java.lang.String)
public PageDefinition getPageDefinitionDirectly(java.io.Reader reader, java.lang.String ext) throws java.io.IOException
Execution
reader
- used to input the raw content of the page. It must be in ZUML.ext
- the default extension if the content doesn't specify
an language. In other words, if
the content doesn't specify an language, LanguageDefinition.getByExtension(java.lang.String)
is called.
If extension is null and the content doesn't specify a language,
the language called "xul/html" is assumed.
java.io.IOException
Execution.getPageDefinitionDirectly(String, String)
,
Execution.getPageDefinitionDirectly(Document, String)
,
Execution.getPageDefinition(java.lang.String)
public void setHeader(java.lang.String name, java.lang.String value)
Execution.setResponseHeader(java.lang.String, java.lang.String)
.
ExecutionCtrl
public void setDateHeader(java.lang.String name, long value)
Execution.getNativeResponse()
instead.
ExecutionCtrl
public void addHeader(java.lang.String name, java.lang.String value)
Execution.addResponseHeader(java.lang.String, java.lang.String)
.
ExecutionCtrl
public void addDateHeader(java.lang.String name, long value)
Execution.getNativeResponse()
instead.
ExecutionCtrl
public void setContentType(java.lang.String contentType)
ExecutionCtrl
public boolean isBrowser()
Execution
public boolean isBrowser(java.lang.String type)
Execution
type
- the type of the browser.
Allowed values include "robot", "ie", "ie6", "ie6-", "ie7", "ie8", "ie8-"
"ie7-", "gecko", "gecko2", "gecko3", "gecko2-", "gecko3-"
"opara", "safari",
"mil", "hil", "mil-". Otherwise, it matches whether the type exist or not.public boolean isRobot()
Execution
Because there are too many robots, it returns true if the user-agent is not recognized.
public boolean isExplorer()
Execution
Execution.isExplorer7()
is true.
public boolean isExplorer7()
Execution
public boolean isGecko()
Execution
public boolean isGecko3()
Execution
public boolean isOpera()
Execution
public boolean isSafari()
Execution
public boolean isMilDevice()
public boolean isHilDevice()
Execution
Note: ZK Mobile for Android supports both MIL and HIL.
That is, both Execution.isHilDevice()
and Execution.isMilDevice()
return true.
public java.lang.String getUserAgent()
Execution
Note: it doesn't return null, so it is easy to test what
the client is with String.indexOf(int)
.
public java.lang.Object getNativeRequest()
Execution
The returned object depends on the Web container. If it is based Java servlet container, an instance of javax.servlet.ServletRequest is returned.
public java.lang.Object getNativeResponse()
Execution
The returned object depends on the Web container. If it is based Java servlet container, an instance of javax.servlet.ServletResponse is returned.
public java.lang.Object getAttribute(java.lang.String name)
Execution
public boolean hasAttribute(java.lang.String name)
Scope
Notice that null
is a valid value, so you can
tell if an attribute is assoicated by examining the return value
of Scope.getAttribute(java.lang.String)
.
public java.lang.Object setAttribute(java.lang.String name, java.lang.Object value)
Execution
value
- the value. If null, the attribute is removed.
public java.lang.Object removeAttribute(java.lang.String name)
Execution
public java.util.Map getAttributes()
Execution
public boolean addScopeListener(ScopeListener listener)
Scope
public boolean removeScopeListener(ScopeListener listener)
Scope
public java.lang.String getHeader(java.lang.String name)
Execution
String
,
or null if not found.
public java.util.Iterator getHeaders(java.lang.String name)
Execution
Iterator
of String
objects.
If the request did not include any headers of the specified name,
this method returns an empty Iterator
.
If the container does not allow access to header information,
it returns null.
public java.util.Iterator getHeaderNames()
Execution
Iterator
.
If the container does not allow access to header information,
it returns null.
public void setResponseHeader(java.lang.String name, java.lang.String value)
Execution
value
- the additional header value If it contains octet string,
it should be encoded according to RFC 2047
(http://www.ietf.org/rfc/rfc2047.txt).Execution.containsResponseHeader(java.lang.String)
public void addResponseHeader(java.lang.String name, java.lang.String value)
Execution
value
- the additional header value If it contains octet string,
it should be encoded according to RFC 2047
(http://www.ietf.org/rfc/rfc2047.txt).public boolean containsResponseHeader(java.lang.String name)
Execution
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |