On Wed, 13 Dec 2006, Marc Logghe wrote:

> I would like to achieve that the default behaviour is wrapping (e.g.
> inherit from autohandler) but *not* in the case of an Ajax request
> (don't know what is The Best Way To Do(tm) that, simple 'nowrap=1'
> option in url or some advanced accept header checking ?)

You might want to wrap the contents in an XML structure and a CDATA block 
in case it's an Ajax request. Anyway, I'd recommend doing the checks in 
the autohandler so that your autohandler can determine if it's a page 
request or an Ajax request. This determination can be based on the 
component name, component path, component attributes or even the query 
string.

Here's one way of controlling wrapping per component, with an attribute 
section and a default of "on".

In your autohandler:

my $print_header_and_footer = 1;
if ($m->request_comp->attr_exists('print_header_and_footer')) {
         $print_header_and_footer =
                $m->top_comp->attr('print_header_and_footer');
}

## some other stuff here..?

$m->comp('/your_header_file.html') if ($print_header_and_footer);
$m->call_next;
$m->comp('/your_footer_file.html') if ($print_header_and_footer);


and then in the component you can turn the wrapping off with

<%attr>
        print_header_and_footer => 0
</%attr>

but still get the other stuff autohandler possibly does besides 
the printing.

------------------------------------------------------------------------
Oskari "Okko" Ojala
Frantic Media

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to