You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Henning Schmiedehausen (JIRA)" <de...@velocity.apache.org> on 2007/03/08 01:10:33 UTC

[jira] Closed: (VELOCITY-89) 1.3 templates incompatible with ones that worked on 1.2

     [ https://issues.apache.org/jira/browse/VELOCITY-89?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henning Schmiedehausen closed VELOCITY-89.
------------------------------------------


> 1.3 templates incompatible with ones that worked on 1.2
> -------------------------------------------------------
>
>                 Key: VELOCITY-89
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-89
>             Project: Velocity
>          Issue Type: Bug
>          Components: Engine
>    Affects Versions: 1.3-rc1
>         Environment: Operating System: All
> Platform: Other
>            Reporter: Andriy Rozeluk
>         Assigned To: Velocity-Dev List
>
> First off, Velocity is absolutely excellent! Been using it since the first
> release, and have definitely not regretted the decision to use this instead of
> JSP/Webmacro/etc.
> I downloaded Velocity 1.3, and unfortunately there appears to be a bug in this
> release, running code which works just fine on 1.2.
> First, I added to the Context a utility class that I use frequently under the
> name 'utility', which basically has the following:
>   public Object arrayGet( Collection c, int index ) {
>     return arrayGet( c.toArray(), index );
>   }
>   public Object arrayGet( Object[] array, int index ) {
>     if ( index >= 0 && index < array.length ) {
>       return array[ index ];
>     }
>     else {
>       return null;
>     }
>   }
> (don't ask - it solved a problem for me in the past and it's worked great ever
> since)
> Next, an example template might have:
> #set ( $colour_tablelines = ["#FFFFFF","lightblue"] )
> #set ($count = 0)
> #foreach($c in $items)
>   #set( $currentcol = $count % 2 )
>   #set( $backcolour = ${utility.arrayGet( ${colour_tablelines},$currentcol )} )
>   <tr bgcolor="$!{backcolour}">
> ... etc etc
>   </tr>
> #end
> The idea, of course, is to alternate the colours of the lines to make the page
> easier to read. Perhaps not an optimal solution, but it worked great with every
> release of Velocity <= 1.2.
> Unfortunately with 1.3, I get the following in my log instead:
> Mon Jul 08 11:45:04 EDT 2002  [error] RHS of #set statement is null. Context
> will not be modified. mytemplate.vm [line 250, column 1]
> Mon Jul 08 11:45:04 EDT 2002   [warn]
> org.apache.velocity.runtime.exception.ReferenceException: reference : template =
> mytemplate.vm [line 268,column 18] : ${backcolour} is not a valid reference.
> While I'm definitely open to suggestions as to how to make this code a bit
> cleaner, the underlying problem is that I have many templates and changing them
> all would be a lot of work. I'd prefer if it were possible to maintain
> compatibility with previous releases of Velocity. For now, I am noting this
> issue and continuing with my testing to see if there are any more incompatibilities.
> Thanks for your efforts!

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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