[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cgiapp] 2nd & 3rd run modes not working


Hello

 

I just installed CGI::Application ver. 3.31 on a server running Red Hat
Enterprise Linux.

I wrote a simple program to test the functionality of this application
manager and have encountered a problem.

 

The start page (mode1) loads properly and redirects to mode2 when submit is
clicked (as it should).

 

Unfortunately mode2 does not call mode3, it calls itself.  After viewing the
HTML source of the page mode2 I discovered that the hidden 'rm' variable has
the value 'mode2' in the HTML code despite the perl program specifying
'mode3'.  I have marked the lines in the HTML and Perl code below with
'***'.

 

Similarly, when I navigate to the mode3 page by typing in
"URL?rm=mode3&colour=green", the 'rm' value is 'mode3' rather than 'mode2'
as specified in the perl code.

 

It appears to me that the current mode is being used for the next 'rm' value
rather than the specified next value.

Any ideas why this may be happenning?  Is there a bug in version 3.31?  Am I
just missing something?

 

Any help is greatly appreciated.

Thanks, 

Matt

 

 

Source from run mode 2: (Browser: IE 6.0 in WinXP Pro)

-----------------------

<?xml version="1.0" encoding="iso-8859-1"?>

<!DOCTYPE html

      PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>

<html xmlns="http://www.w3.org/1999/xhtml"; lang="en-US"
xml:lang="en-US"><head><title>Run Mode 2 - Get colour</title>

</head><body><form method="post" action="/<path>/run_myapp.pl"
enctype="application/x-www-form-urlencoded">

<h3>Welcome matt.</h3><p>What is your favourite colour? <input type="text"
name="colour"  size="15" maxlength="15" />***<input type="hidden" name="rm"
value="mode2"  />***<input type="submit" name=".submit" /><div></div>

</form></body></html>

 

 

myapp.pm

---------------

package myapp;

use base 'CGI::Application';

use strict;

 

sub setup {

        my $self = shift;

        $self->run_modes(

                'mode1' => 'show_login_form',

                'mode2' => 'get_colour',

                'mode3' => 'display_colour',

        );

        $self->start_mode('mode1');

        $self->mode_param('rm');

}

 

# mode1

sub show_login_form {

        my $self = shift;

        my $q = $self->query();

        my $output = "";

        $output .= $q->start_html(-title => "Run Mode 1 - Login");

        $output .= $q->start_form();

 

        $output .= "Username: ";

        $output .= $q->textfield(-name => 'username');

        $output .= "<p>Password: ";

        $output .= $q->password_field(-name =>'password', -size=>20,
-maxlength=>20);

 

        $output .= $q->hidden(-name => 'rm', -value => 'mode2');

        $output .= $q->submit();

        $output .= $q->end_form();

        $output .= $q->end_html();

 

        return $output;

}

 

# mode2

sub get_colour {

        my $self = shift;

        my $q = $self->query();

        my $name = $q->param('username');

        my $output = "";

 

        $output .= $q->start_html(-title => "Run Mode 2 - Get colour");

        $output .= $q->start_form();

        $output .= "<h3>Welcome $name.</h3><p>";

        $output .= "What is your favourite colour? ";

        $output .= $q->textfield(-name => 'colour', size =>15,
-maxlength=>15);

 

        $output .= $q->hidden(-name => 'rm', -value => 'mode3');  # ***
Specifies next run mode is "mode3" ***

        $output .= $q->submit();

        $output .= $q->end_form();

        $output .= $q->end_html();

 

        return $output;

}

 

# mode3

sub print_colour {

        my $self = shift;

        my $q = $self->query();

        my $colour = $q->param('colour');

        my $output = "";

        $output .= $q->start_html(-title => 'Run Mode 3 - Print colour');

        $output .= $q->start_form();

 

        $output .= "Thanks for participating.<p>";

        $output .= "Three people agree that $colour is the best colour!";

 

        # new Run mode - go back to colour page

        $output .= $q->hidden(-name => 'rm', -value => 'mode2');  # *** HTML
source sets 'rm' to 'mode3' (not shown) ***

        $output .= $q->submit();

        $output .= $q->end_form();

        $output .= $q->end_html();

 

        return $output;

}

 

1;

 

 

--

Matthew J. Myhre

Bioinformatics

 <mailto:suppressed> suppressed

 <http://www.rhodococcus.ca/> http://www.rhodococcus.ca/

 

Microbial Envirogenomics

Rm 300-6174 University Blvd.

The University of British Columbia

B.C., Canada, V6T 1Z3

 

Ph:  (604) 827-5160

Fax: (604) 822-6041

 


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.