velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob Kischuk <RKisc...@sprich.com>
Subject RE: Macro not evaluating
Date Wed, 14 Jul 2004 20:54:34 GMT
Got it working, it was definitely the parameter type not matching that of
the target method that cause the failure.

> well, it's hard to tell the difference between $this.is.nothing and
> $this.should.be.evaluated.  and actually, i think it does log "not a valid
> reference" messages in most cases.

In this case, it didn't.  I understand the dilemma there, but given that
Velocity provides a clear way of escaping \$this.is.nothing, an evaluation
of $this.is.nothing should be attempted, and some message logged.  In the
case of ${<locatedContextObject>.<method>(<params*>)}, I would make the
case
that since the object has been found in the context, a message to the effect
of "Template email.vm, line 52: method Formatter.leftPad(Integer, int) is
not defined."

Once again, thanks to the developers for all that has been done to make
Velocity so useful.  This is just a suggestion to make it more
developer-friendly.

Thanks,
	Rob

-----Original Message-----
From: Nathan Bubna [mailto:nathan@esha.com] 
Sent: Wednesday, July 14, 2004 12:56 PM
To: Velocity Users List
Subject: Re: Macro not evaluating

Rob Kischuk said:
> Good call - it wasn't the capitalization... that was a typo on my part as
I
> snipped my code for mailing list consumption.

:)

> I think the problem is actually the argument type.  Quantity is actually
an
> Integer, so I'm calling for (Integer, int), but the method is written as
> (String, int).

a robust fix would be to change your macro to:

#macro( leftpad $message )
${formatter.leftpad("$!message", 8)}
#end

this should automatically and reasonably handle non-String values, as well
as
null values.

> Thanks for the help.  Is there are reason that Velocity dies so silently,
> without even a log message when it can't evaluate an expression?
...

well, it's hard to tell the difference between $this.is.nothing and
$this.should.be.evaluated.  and actually, i think it does log "not a valid
reference" messages in most cases.

Nathan Bubna
nathan@esha.com


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

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


Mime
View raw message