Server-side Processing
Process AU Requests at Server
A widget event (Event) is converted to an AU request and then sent to the server. When the event arrives at the server, it is converted to be an instance of AuRequest), and then pass to the desktop for serving by invoking DesktopCtrl.service(AuRequest, boolean). If the request is targeting a component, the component's ComponentCtrl.service(AuRequest, boolean) will then be called to serve it.
Component State Synchronization
Thus, if you implement a component, you could override ComponentCtrl.service(AuRequest, boolean) to handle it.
Here is an example (from Radio):
public void service(org.zkoss.zk.au.AuRequest request, boolean everError) {
final String cmd = request.getCommand();
if (cmd.equals(Events.ON_CHECK)) {
CheckEvent evt = CheckEvent.getCheckEvent(request);
_checked = evt.isChecked();
fixSiblings(_checked, true);
Events.postEvent(evt);
} else
super.service(request, everError);
}
Application-level Notification
If the AU request is sent by an application for custom service, you could implement AuService to serve it and then plug it to the targeted component or desktop, depending on your requirement. If the request is targeting a desktop, you can only intercept it at the desktop-level. If targeting a component, you could intercept it at either component-level or desktop-level.
Intercept at Desktop-level
To plug it to the desktop, you could implement a listener of DesktopInit to add it to a desktop by Desktop.addListener(Object). Then, specify the listener to WEB-INF/zk.xml. For example,
package foo;
public class FooDesktopInit implements DesktopInit {
public void init(Desktop desktop, Object request) throws Exception {
desktop.addListener(new FooAuService()); //assume you have a custom service called FooAuService
}
}
and, in WEB-INF/zk.xml
<listener>
<listener-class>foo.FooDesktopInit</listener-class>
</listener>
Intercept at Component-level
To plug it to the component, you could invoke Component.setAuService(AuService).
Important Events
Version History
Version | Date | Content |
---|---|---|