DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10557>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10557 1.3 templates incompatible with ones that worked on 1.2 Summary: 1.3 templates incompatible with ones that worked on 1.2 Product: Velocity Version: 1.3-rc1 Platform: Other OS/Version: Windows NT/2K Status: NEW Severity: Normal Priority: Other Component: Source AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] 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! -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
