When you build your project, Project Builder builds both the individual Java .class files and a .jar file containing the entire ClientSideJava subproject. This way, you have the option of using WOApplet's archive binding for browsers that support .jar files.
public class MyApplet extends Applet implements SimpleAssociationDestination { .... }
public Vector keys() { Vector keys = new Vector(1); keys.addElement("title"); return keys; }
synchronized public Object valueForKey(String key) { if (key.equals("title")) { return this.getLabel(); } } synchronized public void takeValueForKey(Object value, String key) { if (key.equals("title")) { if ((value != null) && !(value instanceof String) { System.out.println("Object value of wrong type set for key 'title'. Value must be a String."); } else { this.setLabel(((value == null) ? "" : (String)value)); } }
You should be able to access the keys directly or, ideally, through accessor methods (in this example, getLabel and setLabel). It is a good idea to use the synchronized modifier with takeValueForKey and valueForKey because these methods can be invoked from other threads to read or set data.
The value for a key must be a property-list type of object (either singly or in combination, such as an array of string objects). The corresponding property-list type of objects for Objective-C and Java are:
Objective-C | Java |
NSString | String |
NSArray | Vector |
NSDictionary | Hashtable |
NSData | byte[] |
protected Association _assoc; ... synchronized public void setAssociation(Association assoc) { _assoc = assoc; }
The Association object must be stored so that it can be used later as the receiver of the invokeAction message. The Association forwards the action to the AppletGroupController, which handles the invocation of the server-side action method.
synchronized public boolean action(Event evt, Object what) { if (_assoc != null) { _assoc.invokeAction("action"); } return true; }
Table of Contents Next Section