Directives and tools are definitely "legal" code too! Velocity is
made to be extensible in various ways (custom directives, loggers,
uberspect, event handlers, resource managers, resource loaders, etc).
those all have their appropriate and "legal" place too. :)
8/1/06, Matthias Hendler <hendler2 (AT) gmx (DOT) dewrote:
Hello,
well, perhaps you can do it with vm.
--
You can define an macro which sets a defined variable with the desired object.
--
So in your template:
--
#createModel($myModel)
Now in $myModel the desired model object goes.
--
So in the global vm library
--
#macro( createModel $myPar1 )
do something like accessing the business logic object in the velocity context
#set($myPar1 = whatever)
#end
--
Well, I think you must have the view, business logic and model be present in the velocity context. you can't access them.
So I would prefer the solution with macros, cause its legal code and you dont have to hack velocity.
It's also easy to load the macros from more than one file.
--
Regards
Matthias
>
>
>
>
>
Nachricht
Datum: Tue, 1 Aug 2006 00:16:25 +0400
Von: "Maxim Gordienko" <mgordienko (AT) gmail (DOT) com>
An: "Velocity Users List" <velocity-user (AT) jakarta (DOT) apache.org>
Betreff: Re: Defining velocimacro in java class
The reason is quite simple. The macro logic is quite complicated and
cumbersome. It hardly can be implemented in velocity template.
It's legacy architecture "feature" - view asks business logic for a model.
Maybe I do not need macro and directive works just well. I need to
define some kind of "shortcut" for view developer who can use it in
any view. And a logic behind this "shortcut" is actually evaluated
only if velocity engine encounter "shortcut" in rendered view.
Can you point out where i can find info about custom directive?
Thank you!
7/31/06, Nathan Bubna <nbubna (AT) gmail (DOT) comwrote:
Is there some particular reason you want to attach the macro to a
specific context? If you are just wanting to define a "Velocimacro"
in a java class, than you can create a custom directive. But those
must be associated with a VelocityEngine before initialization.
Your other option would be to "Use A Tool". This could be a tool
that takes advantage of the VelocityTools support or just any old
PJ Have it take the parameters you want and generate the output
you want. Then you just put it in your context and use it.
than these alternatives, no, i don't believe it is possible to
define a Velocimacro in a java class and attach it to a specific
context.
7/30/06, Maxim Gordienko <mgordienko (AT) gmail (DOT) comwrote:
Hello!
Is it possible to define Velocimacro in java class (implementing some
interface, extending some base class etc.), somehow register it in
context and use it just like macro defined inline or in macros
library?
Thank you.
To unsubscribe, e-mail: velocity-user-unsubscribe (AT) jakarta (DOT) apache.org
For additional commands, e-mail: velocity-user-help (AT) jakarta (DOT) apache.org
>
>
>
To unsubscribe, e-mail: velocity-user-unsubscribe (AT) jakarta (DOT) apache.org
For additional commands, e-mail: velocity-user-help (AT) jakarta (DOT) apache.org
>
>
>
To unsubscribe, e-mail: velocity-user-unsubscribe (AT) jakarta (DOT) apache.org
For additional commands, e-mail: velocity-user-help (AT) jakarta (DOT) apache.org
--
--
Echte DSL-Flatrate dauerhaft 0,- Euro*. Nur noch kurze Zeit!
"Feel free" mit GMX DSL: http://www.gmx.net/de/go/dsl
To unsubscribe, e-mail: velocity-user-unsubscribe (AT) jakarta (DOT) apache.org
For additional commands, e-mail: velocity-user-help (AT) jakarta (DOT) apache.org
--
To unsubscribe, e-mail: velocity-user-unsubscribe (AT) jakarta (DOT) apache.org
For additional commands, e-mail: velocity-user-help (AT) jakarta (DOT) apache.org