On Thu, Apr 15, 2010 at 17:54, stefan bachert <stefanbachert(a)yahoo.de> wrote:
Hi,
I have several macro {{macro /}}-Stil. Depending on the place inside/outside a velocity
macro I get could read vars changed by a macro, or not.
This is not satifying.
I try putting the value into the context with context.put
However, this value is killed when the programming flow has left the macro
How do return a value from a macro?
The exact "return a value from a macro" is impossible since macro only
produce rendering blocks, the only thing you can do is to store the
value in some context (choices are ExecutionContext, XWikiContext,
ScriptContext and VelocityContext).
Only thing you can access without programming right in velocity macro
is the VelocityContext, what you can do is put what you want to put in
your macro in the VelocityContext and you will get it has direct
binding in the following velocity macro. In java you can access the
VelocityContext from the XWikiContext using context.get("vcontext").
For example, if you do vcontext.put("myvar", myvar); you can then
access it in the following velocity macro using:
{{velocity}}
$myvar
{{/velocity}}
Now if the only job of your macro is to return something it probably
mean that what you need is a velocity macro and not a xwiki/2.0 macro.
Stefan Bachert
__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen
Massenmails.
http://mail.yahoo.com
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users
--
Thomas Mortagne