velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Miller" <>
Subject Re: Variable method name in a macro?
Date Tue, 08 Oct 2002 07:44:30 GMT
Hi Terry,

Responses inline...

> Just to be very clear: Velocity does *not* retrieve properties, public or
> not.  It will *only* invoke public methods.  And, using Reflection, if
> 'propertyName' refers to a method, the 'getter' method would have to be
> 'getpropertyName()'.

you mean getPropertyName()?

Yep, sorry I guess my description was confusing, however I am aware of the
way this works. I have something like the following:

class Book {
  private String title;
  public String getTitle() {
    return title;
  public void setTitle(String title) {
    this.title = title;
  // etc ....

> Maybe you could just confirm that, and then let's see about additional
> questions. ( I make extensive use of all kinds of tools, with all kinds of
> parameters passed to them.  So I know it works.)
> Regards,
> Terry
> PS: And regardless of the above, if you want something like this:
> $yyy$zzz),
> I believe you should restate it as this: #set($xxx= "$yyy$zzz").
> Furthermore, I find that occasionally when I string varbs together, the
> parser gets confused.  If that were to have happened in the above example,
> what I'd try would be this: #set($xxx= "${yyy}${zzz}").

That's not what I'm after though. What I really want is a way to pass this
exact string (excluding the quotes) through to my tool:


The catch of course is that the String "title" needs to be evaluated by
Velocity first, since I am retrieving the value from elsewhere in the
context. So, similar to what Aapo is after, I only want to evaluate the
second half of the expression (ie the method name), and then pass the whole
string through to my eval() method which will then effectively evaluate the
expression a second time.


$book.$propertyName  ## Only evaluate the $propertyName
$book.title          ## Result of the first evaluation
The Lord of the Rings    ## Result of the second evaluation (ie, the result
of the call to $tool.eval("$book.title"))

Thanks for your patience so far :-)

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message