WebObjects Viewed Through Its Classes
Table of Contents Previous Section
Associations and Client-Side Java Components
Client-side Java components, like server-side dynamic elements, use associations to synchronize state with the parent component. However, the association class they use is not the same. Instead of using next.wo.Association (the WOAssociation equivalent in Java), they use next.wo.client.Association, and this Association class is downloaded to the client along with the component itself.
Keys for a client-side component fall into two groups: state bindings and action bindings. State bindings form the basis for state synchronization by associating state in the applets with state in the server. Action bindings associate particular events in the client applet (such as clicking a button) with the invocation of methods in the server.
State is synchronized between the client and the server in three phases:
- When a page is first generated, the server sends the client all state for which there are bindings.
- Before an action is invoked in the server, the client sends the server any of its state that has changed.
- After the action is completed, the server sends the client any of its state that has changed.
This last synchronization occurs only if no new page is returned to the browser. When a method invoked remotely through an applet action binding returns null, it signals that, instead of returning a new page, the server should resynchronize its state with the applets on the page. WebObjects takes a snapshot of the changes in state in the server so that only the state that has changed is sent back to the client.
Note: The last two phases of the synchronization cycle can be initiated only on the browser side. That is, except for the first "initialization" phase, the server component can react only to an action triggered in an applet. The component cannot unilaterally update the state of an applet when its own state changes.
Table of Contents Next Section