[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mason
Subject:    Re: [Mason] passing data to a mason component and disabling
From:       "Anthony Ettinger" <ettinger () gmail ! com>
Date:       2008-12-17 0:38:37
Message-ID: 3fc6b2fb0812161638k497cf020r4137f8ad97894d74 () mail ! gmail ! com
[Download RAW message or body]

On Tue, Dec 16, 2008 at 4:31 PM, Jonathan Swartz <swartz@pobox.com> wrote:
> This is probably most helpful:
> 
> http://www.masonhq.com/?FAQ:Components#h-i_m_trying_to_generate_an_image_or_other_binary_file__but_it_seems_to_be_getting_corrupted_
>  
> On Dec 16, 2008, at 4:23 PM, Anthony Ettinger wrote:
> 
> > I have a page, results.html
> > The page shows search results for a given set of criteria...I have
> > added an "Export" button that reposts the same search criteria but
> > intercepts the display and calls a mason component that delivers a
> > comma-separate-value file for download.
> > 
> > This works fine, except that I'm still getting the header/footer html
> > from ./pages/autohandler.
> > This is how I'm calling the sub request:
> > 
> > ./pages/results.html has this at the bottom of <%init>
> > 
> > <%init>
> > ...
> > if ( $action eq 'export' ) {
> > $m->comp('/csv', filename => 'results.csv', csv_data => $result_hash);
> > }
> > </%init>
> > 
> > I'm having a difficult time finding a way to disable the
> > ./pages/autohandler from being used, typically the component would
> > have a flag that disables inheritance:
> > <%flag>
> > inherit => undef
> > </%flag>
> > 
> > ...but when I call the 'csv' component this way, it is still using the
> > ./pages/results.html autohandler.
> > 
> > Is there a way to dynamically disable the autohandler from inside the
> > <%init> block of results.html?
> > Or is there a better way to pass the $result_hash (all the data from
> > the search results in results.html) into a new page request? (I don't
> > want to have to duplicate all the code that gets the results hash from
> > the DB in two different places).
> > 


Thanks Jonathan,

For anyone else interested, I just discovered wrapping the call like this works:

if ( $export ) {
    $m->clear_buffer;
    $m->comp('/csv', csv_data => $results, filename => 'results.csv' );
    $m->abort;
}


...it now delivers the file without headers/footers defined in
./pages/autohandler.

http://masonhq.com/docs/manual/Devel.html#internal_redirects


-- 
Anthony Ettinger
408-656-2473
http://anthony.ettinger.name

------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic