Declarations file syntax – Apple WebObjects 3.5 User Manual
Page 36

Chapter 2
Dynamic Elements
36
•
It resolves the value for the
upSince
key by looking for a method named
upSince
in the application object.
If the method is not found, it looks for an
upSince
instance variable. In this
case, the
upSince
instance variable is defined in the application’s code file.
•
It resolves the value for the
description
key by looking for a method named
description
in the
upSince
object.
Because
upSince
is a date object, it defines a
description
method, which prints
the object’s value as a string.
Note:
The Java equivalent of the
description
method is
toString
, but you must use
the WebScript name for methods and literals in the
.wod
file even though
the application is written in Java.
Here are the general rules for binding dynamic element attributes:
•
You must bind to a variable or method accessible by the current component.
(You can also bind to constant values.)
•
If you bind to a method, the method must take no arguments. (If you need
to bind to a method that takes arguments, you can wrap it inside of a method
that doesn’t take arguments.)
•
You can bind to any key for objects that define keys.
For example, dictionary objects store key-value pairs. Suppose you declare
a
person
dictionary that has the keys
name
,
address
, and
phone
. These keys aren’t
really instance variables in the dictionary, but because WebObjects
accesses values using key-value coding, the following binding works:
myString : WOString { value = person.name };
•
You must use the Objective-C names for methods and literals.
Even if your entire application is written in Java, you must use the
Objective-C names for methods and for literals. For example, you must use
YES
instead of
true
,
NO
instead of
false
, and
description
instead of
toString
.
Declarations File Syntax
As you’ve seen, the
.wod
file specifies nearly all of the information necessary to
create a dynamic element. Because you usually create dynamic elements and
their bindings using WebObjects Builder, you normally don’t have to worry
about the syntax of the
.wod
file. However, here it is for the curious: