You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Rickard Öberg <ri...@xpedio.com> on 2001/11/27 17:15:06 UTC

Re: [Webwork-user] Problems with Velocity Context

(Velocity-user CC'ed)

James Cook wrote:

> The majority of property references work, as do macros. The WebWork velocity
> examples work fine, but they hardly stress the implementation.
> 
> An example of strange behavior:
> 
> 	public int getNumber(int number) {
> 		return number;
> 	}
> 
> None of these work:
> 
> 	$number(5)
> 	$getNumber(5)
> 	${getNumber(5)}


As I just explained on the Velocity list, this is probably normal 
behaviour of Velocity. It's not intended to work the way you are trying 
to do it.

If $..getNumber(5) works that's cool, but otherwise I'd suggest either 
making a getNumber() method that returns a list that you can index, or 
make a method that returns the action itself, e.g.:
public Object getAction()
{
   return this;
}
--
Then you can access it using the Velocity syntax "$action.getNumber(5)"

Not squaky clean, but it'd work :-)

/Rickard

-- 
Rickard Öberg


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>