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 / DodgeLite / Main.wo / Main.pl-raw < prev    next >
Encoding:
Text File  |  1996-08-09  |  2.4 KB  |  85 lines

  1. # $Id: Main.pl-raw,v 1.1 1996/07/26 05:17:04 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 Jean-Marie Hullot
  10. #
  11. # The WebScript file for the Main component displays car information such
  12. # as price range, model name, and car types to allow the user to build
  13. # selection criteria.
  14.  
  15. package WO::DodgeLite::Main;
  16. use WOPerl;
  17.  
  18. @IVARS=qw(
  19.   models model selectedModels
  20.   prices price selectedPrices
  21.   types type selectedTypes
  22.   sortBys sortBy selectedSortOrder
  23. );
  24.  
  25. %FLAGS=(
  26.   'rawSet' => 1,
  27. #  'traceSet' => 1,
  28. #  'traceGet' => 1,
  29. #  'traceInvoke' => 1,
  30. );
  31.  
  32. # Initialize variables 
  33. sub awake
  34. {
  35.   print "Main awake (raw types)...\n";
  36.   my $self=shift;
  37.  
  38.   $self->{'models'}=$WOApp->modelsDict->allValues;
  39.   $self->{'types'}=$WOApp->typesDict->allValues;
  40.   $self->{'prices'}=obj([8000, 10000, 12000, 14000, 16000,
  41.              18000, 20000, 25000, 30000, 50000, 90000]);
  42.   $self->{'sortBys'}=obj(["Price", "Type", "Model"]);
  43.   return nil;
  44. }
  45.  
  46. # Formatter for price browser 
  47. sub priceFormat
  48. {
  49.   my $self=shift;
  50.   return "\$ " . $self->{'price'};
  51. }
  52.  
  53. sub displayCars
  54. {
  55.   my $self=shift;
  56.   # Create the second page that will display all the cars matching 
  57.   # the client's criteria
  58.   my $selectedCarsPage = $WOApp->pageWithName("SelectedCars");
  59.  
  60.   $self->{'selectedModels'} = $self->{'models'}
  61.     if !($self->{'selectedModels'}->count);
  62.   $self->{'selectedTypes'}=$self->{'types'}
  63.     if !($self->{'selectedTypes'}->count);
  64.   $self->{'selectedPrices'}=$self->{'prices'}
  65.     if !($self->{'selectedPrices'}->count);
  66.   $self->{'selectedSortOrder'}=obj("Price")
  67.     if nil($self->{'selectedSortOrder'});
  68.  
  69.   # Set the selection parameters expressed by the client
  70.   # (car models, type, price range, ordering).
  71.   # Notice that all these selections (selectedModels, selectedTypes,...)
  72.   # are automatically filled by the declarations. (See Main.wod.)
  73.  
  74.   $selectedCarsPage->setModels($self->{'selectedModels'});
  75.   $selectedCarsPage->setTypes($self->{'selectedTypes'});
  76.   $selectedCarsPage->setPrices($self->{'selectedPrices'});
  77.   $selectedCarsPage->setSortOrder($self->{'selectedSortOrder'});
  78.   $selectedCarsPage->fetchSelectedCars;
  79.  
  80.   return $selectedCarsPage;
  81. }
  82.  
  83. 'WO::DodgeLite::Main';
  84. # EOF
  85.