You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Immanuel Normann <no...@ags.uni-sb.de> on 2003/07/07 12:36:17 UTC
Can a property only have a value if its object is inside a context?
I read in the unser guide how to set properties. e.g.:
#set( $primate = "monkey" )
#set( $customer.Behavior = $primate )
but I get problems if $customer is not in any context. So is it not
possible to assign a value to a property if the according object is not
put in a context by some servlet?
The reason why I want to have it:
In our project one programmer is responsible for the velocity (me) and
the other implements the according serlvets. To make our work modular we
defined the context objects before (it is the interface so to speak).
Now I am almost finished but the servlets are far from being finished.
And I want to test the behaviour of my template with some dummy content
which I simply want to assign to my existing object properties within
the template (so with no need to access any servlet).
How would you do it?
Regards,
Immanuel Normann
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: Can a property only have a value if its object is inside a context?
Posted by Ch...@dlr.de.
Hi,
Only objects in the context are available to the designer. The
set directive will only allow defining new variables from
either strings in the template or output from tool invocations.
So in your case you will need a tool that allows creating your
customer objects. You might simplify your test code by just
creating a map, which will allow setting arbitrary properties
on it.
It is planned for a future release of velocity to give direct
map support from the template syntax.
In the past I've done a complete velocity processing pipeline by
perfoming the following processing steps:
init.vm - At servlet startup (with powerfull tools at hand:
e.g. ClassTool to instantiate arbitrary objects - find it
in the jakarta-commons-sandbox/rupert repository).
The result is cached in a reused ChainedContext.
request.vm - Do the request pre-processing, also supported with powerful
context tools setting up additional thread-unsafe tools.
response.vm - prepares the response, does some common application
preprocessing (security checks, etc.), extracts the
PathInfo part of the request, and parses the desired
response template.
layout.vm - Format the output in a common way.
Please search the velocity arcives for my code and examples. e.g.:
http://www.mail-archive.com/velocity-dev@jakarta.apache.org/msg02901.html
http://www.mail-archive.com/velocity-user@jakarta.apache.org/msg04212.html
http://www.mail-archive.com/velocity-user@jakarta.apache.org/msg08019.html
http://www.mail-archive.com/velocity-user@jakarta.apache.org/msg04209.html
http://www.mail-archive.com/velocity-user@jakarta.apache.org/msg04209/layout.vm
http://www.mail-archive.com/velocity-user@jakarta.apache.org/msg00123.html
Please note that some of the URLs pointing to my sample servers are now
offline.
Cheers,
Christoph
Immanuel Normann wrote:
> I read in the unser guide how to set properties. e.g.:
>
> #set( $primate = "monkey" )
> #set( $customer.Behavior = $primate )
>
> but I get problems if $customer is not in any context. So is it not
> possible to assign a value to a property if the according object is not
> put in a context by some servlet?
>
> The reason why I want to have it:
> In our project one programmer is responsible for the velocity (me) and
> the other implements the according serlvets. To make our work modular we
> defined the context objects before (it is the interface so to speak).
> Now I am almost finished but the servlets are far from being finished.
> And I want to test the behaviour of my template with some dummy content
> which I simply want to assign to my existing object properties within
> the template (so with no need to access any servlet).
> How would you do it?
>
> Regards,
> Immanuel Normann
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
--
:) Christoph Reck
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org