logo       

Re: Structuring my C::A: msg#00080

Subject: Re: Structuring my C::A
Jason,

Take a look at the C::A docs and read up on

prerun_mode() & cgiapp_prerun()

If I understand what you're trying to do, you need something like:

sub setup
{
    my $self    = shift;

    $self->run_modes
    (
        'search' => 'search',
        'view'   => 'view',
        'show_tab1' => 'show_tab1',
        'show_tab2' => 'show_tab2',
        'show_tab3' => 'show_tab3',
    );
}

sub cgiapp_prerun
{
    my $self    = shift;
    my $request = $cgi->query;

    if( $self->get_current_runmode() eq 'search' &&
$request->param('action') ne 'Search' )
    {
        my $tab         = $request->param("tab") || "tab1";
        $self->prerun_mode( show_' . $tab );
    }
}

Hope that helps.

For more information on using cgiapp_prerun, cgiapp_postrun etc, take a look
at my tutorial on the CGI::App Wiki:
http://twiki.med.yale.edu/twiki2/bin/view/CGIapp/OrderOfOperations

---
Steve Comrie


----- Original Message ----- 
From: "Jason A. Crome" <crome@xxxxxxxxxxxxx>
To: <cgiapp@xxxxxxxxxxxxxxxxx>
Sent: Tuesday, February 10, 2004 4:24 PM
Subject: [cgiapp] Structuring my C::A


> Hello again,
>
> Thanks for the help I received on my earlier email :)  Very much
> appreciated.  I'm hoping again for some insight into a problem I'm having.
>
> My C::A has two modes: search and query.  Each mode produces a web page
> consists of one or more "tabs".  In search mode (for example), each tab
> collects some information from the user, then combines that data into a
> database query.
>
> The run modes in C::A rock :)  But what I can't figure out is a good way
> (using C::A methods) to generate data for whatever tab a user selects.  In
> my newbieness, I've only been able to determine a way using some if
> statements.
>
> Sample code looks like this:
>
> sub setup
> {
>     my $self = shift;
>
>     # Set the path to our templates
>     $self->tmpl_path("$config{PATH_BASE}$config{PATH_TMPL}");
>
>     # Declare our various run modes.
>     $self->start_mode('search');
>     $self->mode_param('mode');
>     $self->run_modes('search' => 'search',
>                      'view'   => 'view');
> }
>
> sub search
> {
>     my $self    = shift;
>     my $request = $self->query;
>     my $page;
>
>     # Did the user press search?
>     if($request->param("action") eq "Search")
>     {
>         # detaint
>         # build and execute query
>         # show results page
>     }
>     # - OR -
>     else
>     {
>         # Get and populate the selected tab
>         my $tab         = $request->param("tab") || "tab1";
>
>         $page = show_tab1() if $tab eq "tab1";
>         $page = show_tab2() if $tab eq "tab2";
>         $page = show_tab3() if $tab eq "tab3";
>         # Etc.
>     }
>
>     return $page;
> }
>
> I get some use out of C::A's run modes, but this doesn't seem as if it
makes
> the best use of what C::A has to offer.  Problem is that I can't wrap my
> head around another way of doing it.
>
> Thanks for whatever advice can be offered!
>
> --------------------------------------------------
> Jason A. Crome
> Senior Software Engineer, DEVNET, Inc.
> E-Mail: crome@xxxxxxxxxxxxx
> http://www.devnetinc.com
>
>
>
> ---------------------------------------------------------------------
> Web Archive:  http://www.mail-archive.com/cgiapp@xxxxxxxxxxxxxxxxx/
>               http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
> To unsubscribe, e-mail: cgiapp-unsubscribe@xxxxxxxxxxxxxxxxx
> For additional commands, e-mail: cgiapp-help@xxxxxxxxxxxxxxxxx
>
>


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/cgiapp@xxxxxxxxxxxxxxxxx/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: cgiapp-unsubscribe@xxxxxxxxxxxxxxxxx
For additional commands, e-mail: cgiapp-help@xxxxxxxxxxxxxxxxx




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
linux.arklinux....    user-groups.lin...    kde.usability/2...    ietf.ipp/2002-0...    mail.spam.spamc...    os.netbsd.devel...    audio.cd-record...    text.unicode.de...    php.documentati...    games.fps.halfl...    window-managers...    suse.oracle.gen...    bug-tracking.gn...    video.dvdrip.us...    xfree86.cvs/200...    java.netbeans.m...    network.argus/2...    culture.sf.kill...    debian.ports.al...    freebsd.questio...    qplus.devel/200...    handhelds.palm....   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe