home *** CD-ROM | disk | FTP | other *** search
/ Peanuts NeXT Software Archives / Peanuts-2.iso / Developer / webobjects / extensions / win-nt / WOPerl-lite-10e7.exe / Examples / WOPerl / Visitors / Main.wo / Main.pl < prev    next >
Encoding:
Perl Script  |  1996-08-09  |  1.5 KB  |  52 lines

  1. # $Id: Main.pl,v 1.1 1996/07/26 05:19:06 pedja Exp $
  2. # Main.pl: converted from the original Main.wos
  3. # The original file contains the following notice:
  4. #
  5. #   You may freely copy, distribute, and reuse the code in this example.
  6. #   NeXT disclaims any warranty of any kind, expressed or  implied, as to its
  7. #   fitness for any particular use.
  8. #    
  9. #     Written by Katie McCormick
  10.  
  11. package WO::Visitors::Main;
  12. use WOPerl;
  13.  
  14. @IVARS=qw(number aName WOApp);
  15.  
  16. # In an application or a component script, you can implement an awake
  17. # method to prepare the page and its variables for use during the
  18. # processing of the page. The awake method is the best place to
  19. # initialize variables whose values remain static for the page's
  20. # lifetime (such as a list of hyperlinks), or to modify variables
  21. # whose values only change when the page is first accessed. For
  22. # example, the following awake method increments the visitor count
  23. # each time a visitor accesses the page. The awake method is invoked
  24. # once per transaction.
  25.  
  26. sub awake {
  27.   my $self=shift;
  28.   if (!$self->{'number'}) {
  29.     $self->{'number'}=$WOApp->visitorNum+1;
  30.     $WOApp->setVisitorNum($self->{'number'});
  31.   }
  32.   return $self;
  33. }
  34.  
  35. # This method is invoked when the user presses Return or clicks the Submit
  36. # button. It assigns the value of aName to the global variable lastVisitor
  37. # and then clears the text field.
  38.  
  39. sub recordMe
  40. {    
  41.   my $self=shift;
  42.   if ($self->{'aName'}) {
  43.     $WOApp->setLastVisitor($self->{'aName'});
  44.     #print "name: ",$self->{'aName'},"\n";
  45.     $self->{'aName'}="";
  46.   }
  47.   return;
  48. }
  49.  
  50. 'WO::Visitors::Main';
  51. # EOF
  52.