next up previous contents index
Next: Examples Up: No Title Previous: Aggregation constraints

Actions

Java has a very complicated event-handling API. In many applications such as web page navigators, we just want to describe what to do when a component is clicked. DJ's commands are a very simple construct for describing this kind of actions. A command has the following syntax:
     command(Component,MethodInvocation)
where Component is a component7.1 and MethodInvocation is a call to a method. The command means that when Component is clicked, then execute MethodInvocation. Only one command can be executed for each component. Trying to associate two method invocations with a component will cause an error.

Commands can appear anywhere a constraint can occur. A command has to take a component as the first argument even if the command appears in a component declaration.

MethodInvocation is a call to a method defined some where. The following method

       showDocument(String name)
is a built-in where name is a name or path for a document to be shown when the corresponding component is clicked. Document names are all relative to the code base. It is unnecessary to specify full URL addresses.

Figure [*] is a program that associates an action with every component in the AllComponents object ac.


  
Figure: AllComponentsWithActions.
\begin{figure}
\begin{small}
\begin{tex2html_preform}\begin{verbatim}class AllCo...
... tf.setText(s);
}
}\end{verbatim}\end{tex2html_preform}
\end{small}\end{figure}


next up previous contents index
Next: Examples Up: No Title Previous: Aggregation constraints
Neng-Fa Zhou
1999-02-16