You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Colm McCartan <co...@owl.co.uk> on 2001/11/16 16:55:44 UTC

Thanks! (WAS: I give up!)

Hello all,

thanks for all the responses - this actually exposed my failure to properly 
understand Velocity's casting functionality rather than anything to do with 
escape notation.. 

Despite the fact that I forgot to include my method signature, most people 
noticed that the cast was failing - my method was expecting an int.

16/11/2001 08:03:48, Christoph Reck <Ch...@dlr.de> wrote:
>is the property $document.vnum returning an int or Integer?
>
>Since using the digit 1 works, $user.hasDocPermission seems to be
>requiring an int or Integer as last parameter (the first two params 
>seem strings). Note that velocity will not do typecasting (other than
>Integer to int), so either $document.vnum must return int (or Integer)
>or you will need a context tool that does the conversion.
>
>The poor mans trick (no need to write a context tool) for converting 
>a String to an int:
>#set( $n = 0 )
>if( $user.hasDocPermission("Maintainer", "$document.id", $n.parseInt
($document.vnum) )

This worked fine (and is a handy workaround to remember) but I chose to redesign 
the signatures on my methods anyway. Sticking to strings seemed easiest. (I must 
say, I still can't find the part in the docs that states which casts Velocity 
performs.)

Any comments on the fact that Velocity doesn't log a signature mismatch (which 
doesn't stop it from rocking, of course...)? 

................................................................ 
colm mccartan                        
panasonic owl uk
colmm@owl.co.uk
(44) 131 561 1035



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


Re: Thanks! (WAS: I give up!)

Posted by Nick Bauman <ni...@cortexity.com>.
Colm,

> seemed easiest. (I must  say, I still can't find the part in the docs
> that states which casts Velocity  performs.)

Velocity casts dynamically. You don't need to think about that in the page 
(much).
 
> Any comments on the fact that Velocity doesn't log a signature mismatch
> (which  doesn't stop it from rocking, of course...)? 

It should, that sounds like a bug or we are missing something from your 
picture.
 
> ................................................................ 
> colm mccartan                        
> panasonic owl uk
> colmm@owl.co.uk
> (44) 131 561 1035

-- 
Nick Bauman 
Cortexity Development
Intellectual Process is more important than
Intellectual Property -- you'll see.
http://www.cortexity.com/


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


Re: Thanks! (WAS: I give up!)

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 11/16/01 10:55 AM, "Colm McCartan" <co...@owl.co.uk> wrote:

> Hello all,
> 
> thanks for all the responses - this actually exposed my failure to properly
> understand Velocity's casting functionality rather than anything to do with
> escape notation..
> 
> Despite the fact that I forgot to include my method signature, most people
> noticed that the cast was failing - my method was expecting an int.
> 
> 16/11/2001 08:03:48, Christoph Reck <Ch...@dlr.de> wrote:
>> is the property $document.vnum returning an int or Integer?
>> 
>> Since using the digit 1 works, $user.hasDocPermission seems to be
>> requiring an int or Integer as last parameter (the first two params
>> seem strings). Note that velocity will not do typecasting (other than
>> Integer to int), so either $document.vnum must return int (or Integer)
>> or you will need a context tool that does the conversion.
>> 
>> The poor mans trick (no need to write a context tool) for converting
>> a String to an int:
>> #set( $n = 0 )
>> if( $user.hasDocPermission("Maintainer", "$document.id", $n.parseInt
> ($document.vnum) )
> 
> This worked fine (and is a handy workaround to remember) but I chose to
> redesign 
> the signatures on my methods anyway. Sticking to strings seemed easiest. (I
> must 
> say, I still can't find the part in the docs that states which casts Velocity
> performs.)

Velocity actually performs no casts other than the standard widening that
the reflection API performs for you on method invocation (returning an
Integer from a method that returns int) for example.

There are a few subtle issues regarding method selection, none of which you
ran across in this simple case.

We don't want to do anything magical for you beyond 'safe' things for
convenience.  Casting args and choosing a method is something that I think
that Velocity shouldn't do.

> 
> Any comments on the fact that Velocity doesn't log a signature mismatch (which
> doesn't stop it from rocking, of course...)?

I think that you will find that there might have been a message noting that
$foo.bar was an invalid reference if you look in the log.

If it doesn't, this is a good observation and will be fixed.  Check your log
though...

> 
> ................................................................
> colm mccartan    
> panasonic owl uk
> colmm@owl.co.uk
> (44) 131 561 1035
> 
> 
> 
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 

-- 
Geir Magnusson Jr.                       geirm@optonline.net
System and Software Consulting
You're going to end up getting pissed at your software
anyway, so you might as well not pay for it. Try Open Source.



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