home *** CD-ROM | disk | FTP | other *** search
- # $Id: Main.pl,v 1.1 1996/07/26 05:14:20 pedja Exp $
- # Main.pl: converted from the original Main.wos
- # The original file contains the following notice:
- #
- # You may freely copy, distribute, and reuse the code in this example.
- # NeXT disclaims any warranty of any kind, expressed or implied, as to its
- # fitness for any particular use.
- #
- # Written by Nico Popp
- #
- # The Component application presents a group of digits. When a user
- # clicks a digit, the display is refreshed to reflect the user's
- # selection.
- #
- # The Component application is a simple example of using a subcomponent.
- # The subcomponent (or child component) Palette messages the parent
- # component (Main) using a WOAction object. This works as follows:
- #
- # 1. The parent page (Main) references the child component in its
- # declarations file (Main.wod):
- #
- # PALETTE:Palette {
- # selection = number;
- # callBack = displaySelection;
- # };
- #
- # The callback attribute specified in the declaration takes as its
- # value a method that is triggered when the child component sends the
- # callBack object an invoke message. Through this mechanism the child
- # component is able to message the parent.
- #
- # 2. The child component's script (Palette.pl) uses the action
- # keyword to declare that the callBack specified in the parent's
- # declarations file is a WOAction object:
- #
- # action callBack;
- #
- # 3. The child component's script (Palette.pl) sends the WOAction
- # object callBack an invoke message in its click method,
- # which tells callBack to invoke its associated method, displaySelection.
-
- package WO::Component::Main;
- use WOPerl;
-
- @IVARS=qw(number selection);
- # number: the clicked digit
- # selection: the formatted selection
-
- # This method is called by the Palette component, when
- # a digit (hyperlink) has been clicked
- sub displaySelection
- {
- my $self=shift;
- # The variable 'number' is tied to the Palette component 'selection'
- # variable (look at Main.wod). So if a digit has been set,
- # the selection variable is set to the value of the clicked digit.
- if ($self->{'number'}) {
- $self->{'selection'} = "[$self->{'number'}]";
- } else {
- $self->{'selection'} = "";
- }
- return $self;
- }
-
- 'WO::Component::Main';
- # EOF
-