On 06/02/2011 05:55 PM, Nathan Bubna wrote:
Hi Andreas,
Sorry to have inconvenienced you with this change. The old behavior
was causing problems and had some notable flaws (see my discussion of
the quirks in https://issues.apache.org/jira/browse/VELOCITY-681).
There are no clean workarounds to recover the proxying behavior. You
can set the original reference directly if you know it, of course, but
that could get messy if a variety of references are passed in. You
might also restructure to pass in references to objects or maps so
that changes to the referenced variable are seen in the original
reference when #set on the macro argument reference to that variable.
I know neither of these is ideal.
There is a trick that can be used to achieve the old behavior. I've
detailed the problem here:
http://www.xwiki.org/xwiki/bin/ReleaseNotes/ReleaseNotesXWikiEnterprise30#HMacroevaluationstrategy
The solution is to use #evaluate to set the new value to the original
reference. The loophole that allows this to work is that
"$formalParameterName" expands to "$actualParameterName" when
$formalParameter is undefined/null.
I've written a macro that does this:
https://github.com/xwiki/xwiki-platform/blob/e9051c85ae78fb973f4edbaa968db6bf235eb582/xwiki-platform-core/xwiki-platform-web/src/main/webapp/templates/macros.vm#L1131
You use it by first setting the formal parameter to null, then calling
#setVariable("$formalParameterName" $value).
By the way, will the loophole be preserved in future versions as well,
or is it in danger of being "fixed" at some point?
Sorry.
On Thu, Jun 2, 2011 at 4:04 AM, Andreas Bohnert<a...@weberhofer.at> wrote:
hello velocity user list,
from the 1.7 release on we can not change the value of the original
reference of a macro argument anymore.
this is the change log description:
Calling #set on a macro argument (for which a #set-able reference was
passed) will no longer propagate the new value to the original reference,
but merely set the value of the macro argument reference. This was an
obscure, infrequently used feature and was decided to be more problematic
and unpredictable than useful.
so, is there still a way to change the value of the original reference if I
want to? any workaround?
my knowledge of velocity is limited. I have read this one:
http://wiki.apache.org/velocity/MacroEvaluationStrategy
but I still did not manage to change the value.
any help/example is very much appreciated!!
regards, Andreas
--
Sergiu Dumitriu
http://purl.org/net/sergiu/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org
For additional commands, e-mail: user-h...@velocity.apache.org