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

List:       mason
Subject:    Re: [Mason] [NEWBIE] Conditionally setting autohandler attribute
From:       "P. Fleury" <fleury () users ! sourceforge ! net>
Date:       2004-03-31 20:08:54
Message-ID: 406B2556.40002 () users ! sourceforge ! net
[Download RAW message or body]

Hi Rajesh,

What I tend to do, if you have just a few components with "attributes" 
which may have to be computed, is to use it as a method, and in the 
autohandler, the method reads the attribute as a default behavior.
Your way does not work because the component is parsed and split into 
its Mason portions before any Perl it contains is executed.

Example:

In /autohandler:
<%attr>
    search => 0 # default value if not given
</%attr>
%
<%method search>
% return $m->request_comp->attr('search');
</%method>

In /static_component.html:
<%attr>
    search => 1
</%attr>

In /dynamic_component.html:
<%method search>
% return $cat > 0;
</%method>

Then, when trying to use this, you replace $m->attr('search') by 
$m->scomp('SELF:search') or any other Mason method calling.

mallah@trade-india.com wrote:

>Hi ,
>
>I am new to mason , kindly forgive me if the question is too
>trivial .
>
>in autohandler we have
>
><%attr>
>search => 1
></%attr>
>
>
>in a component which is wrapped by the autohandler above
>i want to set the attribute 'search' conditionally
>
>% if ($cat > 0) {
><%attr>
>	search => 0
></%attr>
>%} else {
><%attr>
>	search => 1
></%attr>
>% }
>
>The above is not working code but i attempts to explain
>what we are trying to achieve. Can anyone please tell me
>what is the correct way to go about it?
>
>
>Regds
>Rajesh Kumar Mallah.
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>-------------------------------------------------------
>This SF.Net email is sponsored by: IBM Linux Tutorials
>Free Linux tutorial presented by Daniel Robbins, President and CEO of
>GenToo technologies. Learn everything from fundamentals to system
>administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
>_______________________________________________
>Mason-users mailing list
>Mason-users@lists.sourceforge.net
>https://lists.sourceforge.net/lists/listinfo/mason-users
>
>  
>


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
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