Hi all,
Elizabeth, what you might want to condsider is that the run mode parameter helps you
indicate what you want your App to do "right
now", and subsequent actions need to be determined subsequently. So if you've got a
sequence of Web form -> Action -> Next Page,
where the order is not completely pre-determined (or even if it is), I'd reccommend
doing something like this:
1) Single run mode param to tell your application which Action to do after the form.
2) The Action run-mode then grabs another form-field parameter from
$self->query()->param('foo') and then sends redirect headers
back to the browser with a new url.
3) That new url points back to the application script with that form parameter as the
new run mode.
In addition to better de-coupling your run modes, you also get the advantage of making
it impossible for the user to accidentally
reload the page and resubmit the form.
HTH,
Stephen
-----Original Message-----
From: William Rico [mailto:[EMAIL PROTECTED]]
Sent: Friday, October 19, 2001 05:41 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: [cgiapp] How to suppress "print" in run()?
> ...
> I have begun to implement the web site using a simple binary state machine
> where the current page, based on user input, directs both the action (if
> any) and the next page. This 'next page' can follow any number of
different
> actions or even no action at all (in the case of a simple navigation). As
> such, I envisioned taking advantage of run modes to implement a two stage
> decision tree - ie, have each current page set an 'action' mode param
value
> and a 'new page' mode param value. Then, I could use run() to invoke the
> first (again, if any) subroutine, change the mode param, and then invoke
the
> second subroutine which would create the output.
Based on this, I understand that you have two parameters that are important
for deciding what your program should do -- the 'action' parameter and the
'new_page' parameter. Let's assume that 'action' is the same thing as run
mode. Based on this, submitting a form or clicking a link within your CGI
App will result in a run mode getting called (which is an action). There's
also the case where there is no action. For this case, I would create a run
mode called 'no_action' that maps to a function no_action().
The last line of each of your run modes should be something like this:
return $self->page($new_page);
(where $new_page is the value of the new_page param)
The page() function would be a simple decision tree:
sub page($$) {
$self = shift;
$new_page = shift;
return $self->show_page_1() if $new_page eq 'page_1';
return $self->show_page_2() if $new_page eq 'page_2';
return $self->show_page_3() if $new_page eq 'page_3';
# ...
return $self->default_page();
}
Let me know if I have this works for you. And good luck!
-Will
William R. Rico
CommonMind
18 W33 St, 2nd Fl
New York, NY 10001
http://www.commonmind.com/
Email: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]