[cgiapp] Multiple run modes
Dan Horne
dan.horne at redbone.co.nz
Wed Feb 6 18:43:26 EST 2008
Mike Tonks said:
> Hi,
>
> I'm looking at CGI::Application prior to use, and one thing is unclear to
> me.
>
> I'll outline a little senario to demonstrate the question:
>
> I have a simple app with four run modes - list, view, edit & update
>
> list does what it say on the tin - lists records in a data table
>
> view ditto, displays a single record
>
> edit displays a form to edit (or add) a record
>
> update sends the posted data to the database
>
>
> In my example, I would like the update run mode to then call the view
> run mode, rather then simply display a rather useless 'update
> complete' message.
>
> Is there a good way to do this with CA? I suppose a simple option is
> to simply have update() call view() and return the results, but I
> wondered if there was a preferred solution to this?
Well you could simply call the view runmode after the update runmode has
run, but there are two recommended ways -
CGI::Application::Plugin::Forward and CGI::Application::Plugin::Redirect.
I prefer the latter, as a refresh of the browser doesn't resubmit the data
(which the first two methods would)
>
> Another thought that occurred from scanning the docs would be to put
> the update function in prerun, but this seems wrong somehow.
>
You probably want to avoid this - it's just getting messy
More information about the cgiapp
mailing list