home *** CD-ROM | disk | FTP | other *** search
- # $Id: Main.pl-pl,v 1.1 1996/07/26 05:17:03 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 Jean-Marie Hullot
- #
- # The WebScript file for the Main component displays car information such
- # as price range, model name, and car types to allow the user to build
- # selection criteria.
-
- package WO::DodgeLite::Main;
- use WOPerl;
-
- @IVARS=qw(models model selectedModels
- prices price selectedPrices
- types type selectedTypes
- sortBys sortBy selectedSortOrder);
-
- # Initialize variables
- sub awakeX
- {
- my $self=shift;
- print "Main awake (object types)...\n";
- $self->{'models'} = pl($WOApp->modelsDict->allValues);
- $self->{'types'}=pl($WOApp->typesDict->allValues);
- $self->{'prices'} = [8000, 10000, 12000, 14000, 16000,
- 18000, 20000, 25000, 30000, 50000, 90000];
- $self->{'sortBys'} = ["Price", "Type", "Model"];
- return;
- }
-
- # This version of awake relies on fact that $WOApp is implemented in WOPerl
- # and that it keeps its ivars as Perl data types...
- sub awake
- {
- my $self=shift;
- print "Main awake (perl types)...\n";
-
- my $href=pl($WOApp)->modelsDict;
- my @mvalues=values(%$href);
- $self->{'models'} = \@mvalues;
-
- $href=pl($WOApp)->typesDict;
- my @tvalues=values(%$href);
- $self->{'types'}= \@tvalues;
-
- $self->{'prices'} = [8000, 10000, 12000, 14000, 16000,
- 18000, 20000, 25000, 30000, 50000, 90000];
- $self->{'sortBys'} = ["Price", "Type", "Model"];
- return;
- }
-
-
- # Formatter for price browser
- sub priceFormat {
- my $self=shift;
- return "\$ $self->{'price'}";
- }
-
- sub displayCars
- {
- my $self=shift;
- # Create the second page that will display all the cars matching
- # the client's criteria
- my $selectedCarsPage = $WOApp->pageWithName("SelectedCars");
- my $x;
- $x=$self->{'selectedModels'};
- if ($#$x<0) {
- $self->{'selectedModels'} = $self->{'models'};
- }
- $x=$self->{'selectedTypes'};
- if ($#$x<0) {
- $self->{'selectedTypes'} = $self->{'types'};
- }
- $x=$self->{'selectedPrices'};
- if ($#$x<0) {
- $self->{'selectedPrices'} = $self->{'prices'};
- }
- $x=$self->{'selectedSortOrder'};
- if (!$x) {
- $self->{'selectedSortOrder'} = "Price";
- }
-
- # Set the selection parameters expressed by the client
- # (car models, type, price range, ordering).
- # Notice that all these selections (selectedModels, selectedTypes,...)
- # are automatically filled by the declarations. (See Main.wod.)
- $selectedCarsPage->setModels($self->{'selectedModels'});
- $selectedCarsPage->setTypes($self->{'selectedTypes'});
- $selectedCarsPage->setPrices($self->{'selectedPrices'});
- $selectedCarsPage->setSortOrder($self->{'selectedSortOrder'});
- $selectedCarsPage->fetchSelectedCars();
-
- return $selectedCarsPage;
- }
-
- 'WO::DodgeLite::Main';
- # EOF
-