|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.zkoss.zk.ui.impl.UiEngineImpl
public class UiEngineImpl
An implementation of UiEngine to create and update components.
| Nested Class Summary | |
|---|---|
static interface |
UiEngineImpl.Extension
An interface used to extend the UI engine. |
| Constructor Summary | |
|---|---|
UiEngineImpl()
|
|
| Method Summary | |
|---|---|
void |
activate(Execution exec)
Activates an execution such that you can access a component. |
boolean |
activate(Execution exec,
int timeout)
Activates an execution such that you can access a component. |
void |
addInvalidate(Component comp)
Invalidates a component to cause redrawing. |
void |
addInvalidate(Page page)
Invalidates the page to cause all of its components to redraw. |
void |
addMoved(Component comp,
Component oldparent,
Page oldpg,
Page newpg)
Called to update (redraw) a component, when a component is moved. |
void |
addResponse(AuResponse response)
Adds a response directly by using AuResponse.getOverrideKey()
as the override key. |
void |
addResponse(java.lang.String key,
AuResponse response)
Adds a response which will be sent to client at the end of the execution. |
void |
addResponse(java.lang.String key,
AuResponse response,
int priority)
Adds a response with the given priority. |
void |
addSmartUpdate(Component comp,
java.lang.String attr,
java.lang.Object value,
boolean append)
Smart-updates a property of the peer widget. |
void |
addSmartUpdate(Component comp,
java.lang.String attr,
java.lang.Object value,
int priority)
Adds a smart update that will be executed at the given priority. |
void |
addUuidChanged(Component comp)
Called before changing the component's UUID. |
protected void |
afterRenderComponents(java.util.Collection<Component> comps)
Called when this engine renders the given components. |
void |
beginUpdate(Execution exec)
Activates and prepare for asynchronous update |
boolean |
ceaseSuspendedThread(Desktop desktop,
EventProcessingThread evtthd,
java.lang.String cause)
Ceases the specified event thread. |
void |
closeUpdate(java.lang.Object ctx)
Deactivates the execution and cleans up. |
Component[] |
createComponents(Execution exec,
PageDefinition pagedef,
Page page,
Component parent,
Component insertBefore,
VariableResolver resolver,
java.util.Map<?,?> arg)
Creates components from the specified page and definition. |
void |
deactivate(Execution exec)
Deactivates an execution, such that other threads could activate and access components. |
void |
desktopDestroyed(Desktop desktop)
Called when a desktop is being removed. |
boolean |
disableClientUpdate(Component comp,
boolean disable)
Sets whether to disable the update of the client widget. |
void |
endUpdate(Execution exec)
Executes posted events, deactivate and ends the asynchronous update. |
void |
execNewPage(Execution exec,
PageDefinition pagedef,
Page page,
java.io.Writer out)
Creates components specified in the given page definition. |
void |
execNewPage(Execution exec,
Richlet richlet,
Page page,
java.io.Writer out)
Invoke Richlet.service(org.zkoss.zk.ui.Page), when a new page is creates upon
visiting a richlet. |
void |
execRecover(Execution exec,
FailoverManager failover)
Executes the recovering. |
void |
execUpdate(Execution exec,
java.util.List<AuRequest> requests,
AuWriter out)
Executes an asynchronous update to a component (or page). |
JSONArray |
finishUpdate(java.lang.Object ctx)
Finishes the update and returns the result in an array of JSON object. |
java.lang.String |
getNativeContent(Component comp,
java.util.List<NodeInfo> children,
Native.Helper helper)
Retrieve the native content for a property of the specified component. |
java.util.Collection<EventProcessingThread> |
getSuspendedThreads(Desktop desktop)
Returns a collection of suspended event processing threads belonging to the specified desktop, or empty if no suspended thread at all. |
boolean |
hasSuspendedThread()
Returns if any suspended event processing thread in the whole system. |
boolean |
isInvalidated(Component comp)
Returns if this component needs to be redrawn. |
void |
notify(Desktop desktop,
java.lang.Object mutex)
Wakes up a single event processing thread for the specified desktop that is waiting on the specified object. |
void |
notify(java.lang.Object mutex)
Wakes up a single event processing thread that is waiting on the specified object. |
void |
notifyAll(Desktop desktop,
java.lang.Object mutex)
Wakes up all event processing threads for the specified desktop that are waiting on the specified object. |
void |
notifyAll(java.lang.Object mutex)
Wakes up all event processing thread that are waiting on the specified object. |
void |
recycleDesktop(Execution exec,
Page page,
java.io.Writer out)
Reuse the desktop and generate the output. |
void |
sendRedirect(java.lang.String uri,
java.lang.String target)
Sends a temporary redirect response to the client using the specified redirect location URL. |
void |
setAbortingReason(AbortingReason aborting)
Aborts the current execution. |
Component |
setOwner(Component comp)
Called before a component redraws itself if the component might include another page. |
void |
start(WebApp wapp)
Starts the engine. |
java.lang.Object |
startUpdate(Execution exec)
Activates an execution that will allow developers to update the state of components. |
void |
stop(WebApp wapp)
Stops the engine. |
void |
wait(java.lang.Object mutex)
Suspends the current processing of an event and wait until the other thread invokes UiEngine.notify(Object), UiEngine.notifyAll(Object),
UiEngine.notify(Desktop, Object) or UiEngine.notifyAll(Desktop, Object)
for the specified object. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public UiEngineImpl()
| Method Detail |
|---|
public void start(WebApp wapp)
UiEngine
start in interface UiEnginepublic void stop(WebApp wapp)
UiEngine
stop in interface UiEnginepublic boolean hasSuspendedThread()
UiEngine
hasSuspendedThread in interface UiEnginepublic java.util.Collection<EventProcessingThread> getSuspendedThreads(Desktop desktop)
UiEngineAn event processing thread is an instance of
EventProcessingThread
getSuspendedThreads in interface UiEnginedesktop - the desktop that the suspended event processing
threads belong to (never null).
public boolean ceaseSuspendedThread(Desktop desktop,
EventProcessingThread evtthd,
java.lang.String cause)
UiEngine
ceaseSuspendedThread in interface UiEnginedesktop - which desktop the event thread belongs tocause - an arbitrary text to describe the cause.
It will be the message of the thrown InterruptedException.
public void desktopDestroyed(Desktop desktop)
UiEngineApplication developers don't need to remove pages and desktops. They are removed and cleaned up automatically.
desktopDestroyed in interface UiEnginepublic Component setOwner(Component comp)
UiEngineIf a new page is created, the specified component will become the owner of the new page.
It must reset the owner in the finally clause.
old = ue.setOwner(this);
try{
...
} finally {
ue.setOwner(old);
}
Since 5.0.6, the owner must implement Includer.
setOwner in interface UiEnginepublic boolean isInvalidated(Component comp)
UiEngineNote:
UiEngine.addInvalidate(Component)
was not called against this component.
isInvalidated in interface UiEnginepublic void addInvalidate(Page page)
UiEngine
addInvalidate in interface UiEnginepublic void addInvalidate(Component comp)
UiEngineComponent.invalidate() is called.
addInvalidate in interface UiEngine
public void addSmartUpdate(Component comp,
java.lang.String attr,
java.lang.Object value,
boolean append)
UiEngine
addSmartUpdate in interface UiEngineappend - whether to append the updates of properties with the same
name. If false, only the last value of the same property will be sent
to the client.
public void addSmartUpdate(Component comp,
java.lang.String attr,
java.lang.Object value,
int priority)
UiEngineUiEngine.addSmartUpdate(Component, String, Object, boolean)
is invoked, the priority is assumed to 0.
If the priority is the same, the update is executed in the order of first-in-first out. You rarely need to control the sequence, unless the update is used to instantiate client-side widgets that other updates might depend on. In this case, it is suggested to specify the priority as 10000 (and not to use priority higher than 10000 for other situation).
addSmartUpdate in interface UiEnginepublic void addResponse(AuResponse response)
UiEngineAuResponse.getOverrideKey()
as the override key.
In other words, it is the same as addResponse(resposne.getOverrideKey(), response)
If the response is component-dependent, AuResponse.getDepends()
must return a component. And, if the component is removed, the response
is removed, too.
addResponse in interface UiEngineUiEngine.addResponse(String, AuResponse)
public void addResponse(java.lang.String key,
AuResponse response)
UiEngineAbstractComponent.response(org.zkoss.zk.au.AuResponse).
Note: Execution.addAuResponse(org.zkoss.zk.au.AuResponse) is a shortcut to this method,
and it is used by application developers.
If AuResponse.getDepends() is not null, the response
depends on the returned component. In other words, the response
is removed if the component is removed.
If it is null, the response is component-independent.
addResponse in interface UiEnginekey - could be anything. If null, the response is appended.
If not null, the second invocation of this method
in the same execution with the same key and the same depends (AuResponse.getDepends())
will override the previous one.UiEngine.addResponse(AuResponse)
public void addResponse(java.lang.String key,
AuResponse response,
int priority)
UiEngineUiEngine.addResponse(String, AuResponse)
and UiEngine.addResponse(AuResponse) is assumed to be 0.
If the priority is the same, the update is executed in the order of first-in-first out.
addResponse in interface UiEngine
public void addMoved(Component comp,
Component oldparent,
Page oldpg,
Page newpg)
UiEngine
addMoved in interface UiEngineoldparent - the parent before movedoldpg - the page before movednewpg - the page after movedpublic void addUuidChanged(Component comp)
UiEngine
addUuidChanged in interface UiEngine
public boolean disableClientUpdate(Component comp,
boolean disable)
UiEngine
disableClientUpdate in interface UiEngine
public void execNewPage(Execution exec,
Richlet richlet,
Page page,
java.io.Writer out)
throws java.io.IOException
UiEngineRichlet.service(org.zkoss.zk.ui.Page), when a new page is creates upon
visiting a richlet.
execNewPage in interface UiEnginejava.io.IOException
public void execNewPage(Execution exec,
PageDefinition pagedef,
Page page,
java.io.Writer out)
throws java.io.IOException
UiEngine
execNewPage in interface UiEnginejava.io.IOException
public void recycleDesktop(Execution exec,
Page page,
java.io.Writer out)
throws java.io.IOException
UiEngine
recycleDesktop in interface UiEnginejava.io.IOExceptionprotected void afterRenderComponents(java.util.Collection<Component> comps)
comps - the collection of components that have been redrawn.
public Component[] createComponents(Execution exec,
PageDefinition pagedef,
Page page,
Component parent,
Component insertBefore,
VariableResolver resolver,
java.util.Map<?,?> arg)
UiEngineUiEngine.execNewPage(org.zkoss.zk.ui.Execution, org.zkoss.zk.ui.metainfo.PageDefinition, org.zkoss.zk.ui.Page, java.io.Writer) or UiEngine.execUpdate(org.zkoss.zk.ui.Execution, java.util.List, org.zkoss.zk.au.AuWriter)
was called.
It assumes the execution is already locked to this desktop.
Note: if both page and parent are null, the created components don't belong to any page/parent.
createComponents in interface UiEngineexec - the execution (never null).pagedef - the page definition (never null).page - the page. Ignored if parent is specified and
parent's page is not null (parent's page will be used).
If both page and parent are null, the created components won't belong
to any page.parent - the parent component, or null if no parent component.
If parent is specified, page is ignored.insertBefore - the sibling component that new components will be
inserted before. Ignored if null (i.e., append as last children).resolver - the variable resolver used to resolve variables.
Ignored if null.arg - a map of parameters that is accessible by the arg variable
in EL, or by Execution.getArg().
Ignored if null.
public void sendRedirect(java.lang.String uri,
java.lang.String target)
UiEngineAfter calling this method, the caller shall end the processing immediately (by returning). All pending requests and events will be dropped.
sendRedirect in interface UiEngineuri - the URI to redirect to, or null to reload the same pagetarget - the new target, or null to denote the same browser windowpublic void setAbortingReason(AbortingReason aborting)
UiEngineNote: if setAbortingReason is ever set with non-null, you CANNOT set it back to null.
After call this method, you shall not keep processing the page because the rendering is dropped and the client is out-of-sync with the server.
setAbortingReason in interface UiEngineaborting - the aborting reason.
public void execRecover(Execution exec,
FailoverManager failover)
UiEngine
execRecover in interface UiEnginepublic void beginUpdate(Execution exec)
UiEngine
beginUpdate in interface UiEngine
public void endUpdate(Execution exec)
throws java.io.IOException
UiEngine
endUpdate in interface UiEnginejava.io.IOException
public void execUpdate(Execution exec,
java.util.List<AuRequest> requests,
AuWriter out)
throws java.io.IOException
UiEngineNote: the output must be XML and UTF-8.
execUpdate in interface UiEnginerequests - a list of AuRequest.
java.io.IOException
public java.lang.Object startUpdate(Execution exec)
throws java.io.IOException
UiEngineIt is designed to implement Bridge.
startUpdate in interface UiEngineUiEngine.finishUpdate(java.lang.Object).
java.io.IOExceptionUiEngine.finishUpdate(java.lang.Object),
UiEngine.closeUpdate(java.lang.Object)
public JSONArray finishUpdate(java.lang.Object ctx)
throws java.io.IOException
UiEngineUiEngine.closeUpdate(java.lang.Object).
It is designed to implement Bridge.
finishUpdate in interface UiEnginectx - the context returned by the previous call to UiEngine.startUpdate(org.zkoss.zk.ui.Execution)
java.io.IOExceptionUiEngine.startUpdate(org.zkoss.zk.ui.Execution),
UiEngine.closeUpdate(java.lang.Object)
public void closeUpdate(java.lang.Object ctx)
throws java.io.IOException
UiEngineIt is designed to implement Bridge.
closeUpdate in interface UiEnginejava.io.IOExceptionUiEngine.startUpdate(org.zkoss.zk.ui.Execution),
UiEngine.finishUpdate(java.lang.Object)
public void wait(java.lang.Object mutex)
throws java.lang.InterruptedException,
SuspendNotAllowedException
UiEngineUiEngine.notify(Object), UiEngine.notifyAll(Object),
UiEngine.notify(Desktop, Object) or UiEngine.notifyAll(Desktop, Object)
for the specified object.
It can only be called when the current thread is processing an event. And, when called, the current processing is suspended and ZK continues to process the next event and finally render the result.
It is typical use to implement a modal dialog where it won't return until the modal dialog ends.
wait in interface UiEnginemutex - any non-null object to identify what to wait, such that
UiEngine.notify(Object) and UiEngine.notify(Desktop, Object) knows
which object to notify.
SuspendNotAllowedException - if there are too many suspended
exceptions.
Deployers can control the maximal allowed number of suspended exceptions
by specifying max-suspended-thread in zk.xml,
or invoking Configuration.setMaxSuspendedThreads(int).
java.lang.InterruptedExceptionpublic void notify(java.lang.Object mutex)
UiEngineUnlike UiEngine.notify(Desktop, Object), this method can be invoked only
if the same desktop is locked for processing requests.
notify in interface UiEnginemutex - any non-null object to identify what to notify. It must be
same object passed to UiEngine.wait(java.lang.Object).UiEngine.notify(Desktop, Object),
UiEngine.notifyAll(Object)
public void notify(Desktop desktop,
java.lang.Object mutex)
UiEngineUnlike UiEngine.notify(Object), this method can be called any time.
It is designed to let working threads resume an event processing
thread.
Notice: if this method is NOT called in an event processing thread, the resumed thread won't execute until the next request is received. To enforce it happen, you might use the timer component (found in ZUL).
notify in interface UiEnginedesktop - the desktop which the suspended thread is processing.
It must be the same desktop of the suspended thread.mutex - any non-null object to identify what to notify. It must be
same object passed to UiEngine.wait(java.lang.Object).UiEngine.notify(Object),
UiEngine.notifyAll(Desktop, Object)public void notifyAll(java.lang.Object mutex)
UiEngineUnlike UiEngine.notify(Desktop, Object), this method can be invoked only
if the same desktop is locked for processing requests.
notifyAll in interface UiEnginemutex - any non-null object to identify what to notify. It must be
same object passed to UiEngine.wait(java.lang.Object).UiEngine.notify(Desktop, Object),
UiEngine.notifyAll(Object)
public void notifyAll(Desktop desktop,
java.lang.Object mutex)
UiEngineUnlike UiEngine.notifyAll(Object), this method can be called any time.
It is designed to let working threads resume an event processing
thread.
If this method is NOT called in an event processing thread, the resumed thread won't execute until the next request is received. To enforce it happen, you might use the timer component (found in ZUL).
notifyAll in interface UiEnginedesktop - the desktop which the suspended thread is processing.
It must be the same desktop of the suspended thread.mutex - any non-null object to identify what to notify. It must be
same object passed to UiEngine.wait(java.lang.Object).UiEngine.notify(Object),
UiEngine.notifyAll(Desktop, Object)public void activate(Execution exec)
UiEngineUiEngine.deactivate(org.zkoss.zk.ui.Execution) in the finally clause.
Note: you RARELY need to invoke this method because UiEngine.execNewPage(org.zkoss.zk.ui.Execution, org.zkoss.zk.ui.metainfo.PageDefinition, org.zkoss.zk.ui.Page, java.io.Writer)
and UiEngine.execUpdate(org.zkoss.zk.ui.Execution, java.util.List will activate and deactivate automatically.
Note: this method can be called only when processing a client request (e.g., HTTP) other than creating a new page and processing async-update.
Also, even if you use this method to grant the right to access components of the specified page, don't post events, create, remove, invalidate and do any smart updates. In other words, READ ONLY.
activate in interface UiEngine
public boolean activate(Execution exec,
int timeout)
UiEngineUiEngine.activate(Execution), you could specify an amount of
time (timeout), and it returns false if it takes longer than the given
amount of time before granted.
activate in interface UiEnginetimeout - the number of milliseconds to wait before giving up.
It is ignored if negative, i.e., it waits until granted if negative.
public void deactivate(Execution exec)
UiEngine
deactivate in interface UiEngine
public java.lang.String getNativeContent(Component comp,
java.util.List<NodeInfo> children,
Native.Helper helper)
UiEngineNativeInfo).
Example:
<html>
<attribute name="content">
<br/>
</attribute>
</html>
getNativeContent in interface UiEnginecomp - the component that the native content will be assigned to.
It is the object that the self variable is assigned when evaluating
EL expressions.children - a list of NativeInfo,
TextInfo and others.
This method evaluates them one-by-one and returns the result
which is the value that will be assigned.helper - the helper used to generate the content.Property
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||