You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Steven Shaw <st...@eiger.co.uk> on 2007/03/02 16:26:44 UTC

velocimacro.context.localscope

What's the downside to using velocimacro.context.localscope = true?
 
Cheers,
Steve.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Re: velocimacro.context.localscope

Posted by Will Glass-Husain <wg...@gmail.com>.
Why does this not work?  Can you

WILL

On 4/13/07, Steven Shaw <st...@eiger.co.uk> wrote:
>
> It seems to be impossible to use velocimacro.context.localscope=true
> with Spring MVC Velocity support. Spring has a macro called springBind
> which side effects a global values called $status. Have the Velocity
> team any thoughts on ideal solutions to this problem?
>
> Cheers,
> Steve.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>


-- 
Forio Business Simulations

Will Glass-Husain
wglass@forio.com
www.forio.com

RE: velocimacro.context.localscope

Posted by Steven Shaw <st...@eiger.co.uk>.
> Why does this not work -- can you be more explicit?

The springBind macro is defined like this:

#macro( springBind $path )
    #if("$!springHtmlEscape" != "")
        #set( $status = $springMacroRequestContext.getBindStatus($path,
$springHtmlEscape) )
    #else
        #set( $status = $springMacroRequestContext.getBindStatus($path)
)
    #end
#end

My understand is that when using velocimacro.context.localscope=true,
the $status variable will be local to the macro. The $status variable is
supposed to be used by subsequent macros.

Steve.

On 4/13/07, Steven Shaw <st...@eiger.co.uk> wrote:
> It seems to be impossible to use velocimacro.context.localscope=true
> with Spring MVC Velocity support. Spring has a macro called springBind

> which side effects a global values called $status. Have the Velocity 
> team any thoughts on ideal solutions to this problem?
>
> Cheers,
> Steve.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>


--
Forio Business Simulations

Will Glass-Husain
wglass@forio.com
www.forio.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Re: velocimacro.context.localscope

Posted by Will Glass-Husain <wg...@gmail.com>.
Why does this not work -- can you be more explicit?

On 4/13/07, Steven Shaw <st...@eiger.co.uk> wrote:
>
> It seems to be impossible to use velocimacro.context.localscope=true
> with Spring MVC Velocity support. Spring has a macro called springBind
> which side effects a global values called $status. Have the Velocity
> team any thoughts on ideal solutions to this problem?
>
> Cheers,
> Steve.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>


-- 
Forio Business Simulations

Will Glass-Husain
wglass@forio.com
www.forio.com

RE: velocimacro.context.localscope

Posted by Steven Shaw <st...@eiger.co.uk>.
It seems to be impossible to use velocimacro.context.localscope=true
with Spring MVC Velocity support. Spring has a macro called springBind
which side effects a global values called $status. Have the Velocity
team any thoughts on ideal solutions to this problem?

Cheers,
Steve.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


RE: velocimacro.context.localscope

Posted by Steven Shaw <st...@eiger.co.uk>.
On 3/2/07, Geir Magnusson Jr. <ge...@pobox.com> wrote:
> changes to the context aren't visible outside of the macro.  I don't 
> think of it as a downside :)

I don't think we have recursive macros. However, since arguments are
passed by name, strange side-effects can take place!

The main problem we are having is code like the following:

  #macro (foo $disabled)
    #if ($disabled)
        #set($disabledAttrib = "disabled='$disabled'")
    #end
    <input $disabledAttrib ...

Because it's not possible to declare $disabledAttrib as a local
variable, it's a global (or context-global I guess). This means that one
disabled button on a form causes the others to be so :).

My recommendation at the moment is to add an else clause:

    #if ($disabled)
        #set($disabledAttrib = "disabled='$disabled'")
    #else
        #set($disabledAttrib = "")
    #end

However, I think that setting velocimacro.context.localscope to true
would also fix this (without having to eyeball and fix all possibly
offending macros). That's why I am asking about the downside. If we
switch to using localscope=true, is there downside - anything to be wary
of?

The only thing I can think if is that intentional assignment to globals
will no longer work. I don't think we do that but it's one downside that
I can think of...

Cheers,
Steve.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Re: velocimacro.context.localscope

Posted by Will Glass-Husain <wg...@gmail.com>.
I've got a user trying to write recursive macros with this option
turned off.  I really wish I'd turned this on by default when I built
my current system.

WILL

On 3/2/07, Geir Magnusson Jr. <ge...@pobox.com> wrote:
> changes to the context aren't visible outside of the macro.  I don't
> think of it as a downside :)
>
>
> geir
>
> On Mar 2, 2007, at 9:26 AM, Steven Shaw wrote:
>
> > What's the downside to using velocimacro.context.localscope = true?
> >
> > Cheers,
> > Steve.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > For additional commands, e-mail: user-help@velocity.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>


-- 
Forio Business Simulations

Will Glass-Husain
wglass@forio.com
www.forio.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Re: velocimacro.context.localscope

Posted by "Geir Magnusson Jr." <ge...@pobox.com>.
changes to the context aren't visible outside of the macro.  I don't  
think of it as a downside :)


geir

On Mar 2, 2007, at 9:26 AM, Steven Shaw wrote:

> What's the downside to using velocimacro.context.localscope = true?
>
> Cheers,
> Steve.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org