PATH  WebObjects 4.5 Documentation > Applet Controls


Previous Section

Introduction

The applets provided by NeXT "wrap" certain graphical user-interface classes in java.awt.*. They also implement the code necessary to interact with an instance of the SimpleAssociation class and thus "push" and "pull" values between the server and the client sides of an application.

A WOApplet dynamic element represents each of these applets on the server side of a WebObjects application. You must initialize this element with the location of the applet's ".class" file, the applet's dimensions, and its association class. You may also initialize any applet-specific key or action. The following is a sample set of assignments made in a declarations (".wod") file:

PASSWORD : WOApplet {
    code = "next.wo.client.controls.TextFieldApplet.class";
    codebase = "/WebObjects/Java";
    width = "200";
    height = "20";
    associationClass = "next.wo.client.SimpleAssociation";
    stringValue = nameString;
    echoCharacter = "*";
    action = "validateUser";
    enabled = isNotValidated; // superclass key (AWTApplet)
};

In this case, the stringValue and echoCharacter attributes are the keys and action is the action of TextFieldApplet. The variable "nameString" is probably declared in the component in which this dynamic element appears whereas "validateUser" is a method of the component that is invoked when the user presses Return in this text field. (Note that methods should be quoted.) The echoCharacter attribute is assigned a string constant.

Notice, however the enabled attribute. This key is not defined by TextFieldApplet, but by its superclass, AWTApplet, which is also the superclass for all NeXT-provided applets. Through inheritance, these derived applets accept values for the keys defined by AWTApplet.

A WebObjects application downloads initial values to the applets after they're created in the browser. These initial values include constants specified in the ".wod" file and values of variables initialized in the component's init methods. Thereafter the values of applet keys are synchronized twice with the variables they are bound to in the WOApplet declaration, once before the triggering of an action method in the server and once again after the method returns nil.


Superclass Attributes

AWTApplet is the base class for the applet controls provided with WebObjects. AWTApplet has keys for common applet attributes: enabled status, foreground color, and background color. The effect of these keys depends on particular applets and particular browsers. For example, no foreground or background colors for a ButtonApplet (other than gray) are allowed. Some browsers do not support certain colors.

enabled
If enabled evaluates to "NO", the applet appears in the page but is not active. The disabled state is manifest differently for each control. For example, a TextFieldApplet will not accept the insertion of a cursor. A disabled button has a grayed-out title and doesn't react to clicks. The default setting is "YES".

foregroundColor
The color of the applet foreground. The foreground of an applet depends upon the type of object. The TextFieldApplet, for example, displays typed text in the foreground color. You must specify colors as a string. The string is either the name of a color (see "Color Names," below) or it may contain six hexadecimal digits to be interpreted in pairs as RGB values. Colors specified as hexadecimal values may start with the "#" character (although this is not required).

backgroundColor
The color of the applet background. The background of an applet depends upon the type of object. The TextFieldApplet, for example, displays the area behind typed text in the background color. You must specify colors as a string. The string is either the name of a color (see "Color Names," below) or it may contain six hexadecimal digits to be interpreted in pairs as RGB values. Colors specified as hexadecimal values may start with the "#" character (although this is not required).


Color Names

The following color names, defined as static class variables by java.awt.Color, are acceptable as string values for the foregroundColor and backgroundColor keys:
blackbluecyandarkGray
graygreenlightGraymagenta
orangepinkredwhite
yellow


A Note on Declaration Synopses

The synopses in this section include the keys and values specific to each applet as well as the specific package name for each applet class file. Ellipses suggest that the other assignments are necessary or possible (codebase or superclass keys, for instance). See the section on standard WOApplet assignments, such as codebase and associationClass, in the "Java Client-Side Components" chapter of the WebObjects Developer's Guide.

Next Section