velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christoph.R...@dlr.de
Subject Re: String to Int
Date Wed, 11 Dec 2002 15:04:32 GMT
Hi Cocosila,

1) You need to place your MyClass instance into the context
    to be able to use it.
    So in Example.java where you do:
	context.put("map", getNames(context));
    also add:
	context.put("MyClass", new MyClass());
2) $Integer also does not exist in the context, whereas $int
    is placed there with the #set($int = 1) statement from
    within the template.
You seem to misunderstand velocity, thinking it allows you
to call static methods of any class from within your
template -> this does not work so. The application developer
(of the java code) defines what the template may see.

You can always test the validity of your context variables
for debugging your template by adding lines like:
     $MyClass.class.name

In another thread of the list I sent a dump.vm example code
that creates a HTML dump of the context variables and their
class (or content for primitive types).

Please note that using reflection all primitive types appear
as theri Object counterparts, but this does not affect the
velocity introspection engine, sine it handles the mapping
transparently. This means that everyting in the context is
an object that implements the getClass() method (only the NULL
does not and gets logged if it was not banged - $!foo).

Hope this helps you a bit further.

:) Christoph


Cocosila wrote:
> Ok, here are all of them.
> 
> I am also confused about $Integer.parseInt("4") that does not "work".
> 
> Dan
> 
> 
> ------------------------------------------------------------------------
> 
> --
> To unsubscribe, e-mail:   <mailto:velocity-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:velocity-user-help@jakarta.apache.org>

-- 
:) Christoph Reck


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


Mime
View raw message