You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Nayana Hegde <na...@cgi.com> on 2004/03/29 12:42:38 UTC

Problem in Velocity Template

Hi ,

 I am facing with a  problem in Velocity Template.

 #foreach ($prod in $!prodlist)
$listTranDemand.substring(0,$listTranDemand.lastIndexOf(",")),----------
 #end

The result of the template as seen from the view source.

$listTranDemand.substring(0,$listTranDemand.lastIndexOf(",")),--------

new Ctran('A1'), new Ctran('A4'), new Ctran('A5'), new Ctran('A7'), new Ctran('A9'), new Ctran('AE'),


In the above  $listTranDemand should have resolved to the value

new Ctran('A1'), new Ctran('A4'), new Ctran('A5'), new Ctran('A7'), new Ctran('A9'), new Ctran('AE')


In the above you can notice that it is resolving correctly in one location and giving an error 
in the other location.

Do you have any idea why it is not resolving correctly.

At this point I got the following error in the velocity.log file

Wed Mar 24 08:16:20 MST 2004  [error] ASTMethod.execute() : exception from introspection : java.lang.NullPointerException
Wed Mar 24 08:16:20 MST 2004   [warn] org.apache.velocity.runtime.exception.ReferenceException: reference : template = TransactionFrame.vm [line 210,column 1] : $listTranDemand.substring(0,$listTranDemand.lastIndexOf(",")) is not a valid reference.

Thanks in advance
Nayana

__________________________________________________
************** Confidentiality Notice ************
 
Proprietary/Confidential Information belonging to 
CGI may be contained in this message. If you are 
not a recipient indicated or intended in this 
message (or responsible for delivery of this 
message to such person), or you think for any 
reason that this message may have been addressed 
to you in error, you may not use or copy or deliver 
this message to anyone else. In such case, you 
should destroy this message and kindly notify the 
sender by reply email.
___________________________________________________

Re: Problem in Velocity Template

Posted by Geir Magnusson Jr <ge...@4quarters.com>.
On Mar 29, 2004, at 5:42 AM, Nayana Hegde wrote:

> Hi ,
>
>  I am facing with a  problem in Velocity Template.
>
>  #foreach ($prod in $!prodlist)
> $listTranDemand.substring(0,$listTranDemand.lastIndexOf(",")),--------- 
> -
>  #end
>

Why are you looping over $prodlist into $prod and not using it in the  
loop?

> The result of the template as seen from the view source.
>
> $listTranDemand.substring(0,$listTranDemand.lastIndexOf(",")),--------
>
> new Ctran('A1'), new Ctran('A4'), new Ctran('A5'), new Ctran('A7'),  
> new Ctran('A9'), new Ctran('AE'),
>
>
> In the above  $listTranDemand should have resolved to the value
>
> new Ctran('A1'), new Ctran('A4'), new Ctran('A5'), new Ctran('A7'),  
> new Ctran('A9'), new Ctran('AE')
>
>
> In the above you can notice that it is resolving correctly in one  
> location and giving an error
> in the other location.
>
> Do you have any idea why it is not resolving correctly.
>

Is it set in the first place?

> At this point I got the following error in the velocity.log file
>
> Wed Mar 24 08:16:20 MST 2004  [error] ASTMethod.execute() : exception  
> from introspection : java.lang.NullPointerException
> Wed Mar 24 08:16:20 MST 2004   [warn]  
> org.apache.velocity.runtime.exception.ReferenceException: reference :  
> template = TransactionFrame.vm [line 210,column 1] :  
> $listTranDemand.substring(0,$listTranDemand.lastIndexOf(",")) is not a  
> valid reference.
>
> Thanks in advance
> Nayana
>
> __________________________________________________
> ************** Confidentiality Notice ************
>
> Proprietary/Confidential Information belonging to
> CGI may be contained in this message. If you are
> not a recipient indicated or intended in this
> message (or responsible for delivery of this
> message to such person), or you think for any
> reason that this message may have been addressed
> to you in error, you may not use or copy or deliver
> this message to anyone else. In such case, you
> should destroy this message and kindly notify the
> sender by reply email.
> ___________________________________________________
>
-- 
Geir Magnusson Jr                                   203-247-1713(m)
geir@4quarters.com


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