You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Tom White (Jira)" <ji...@apache.org> on 2021/09/13 07:35:00 UTC

[jira] [Comment Edited] (VELOCITY-948) Number ranges created as ASTIntegerRange$IntegerRange in 2.1 rather than java.util.ArrayList

    [ https://issues.apache.org/jira/browse/VELOCITY-948?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17413973#comment-17413973 ] 

Tom White edited comment on VELOCITY-948 at 9/13/21, 7:34 AM:
--------------------------------------------------------------

I think the use case was creating a list of dynamic size (according to the size of another object), which is then populated in  a foreach loop. It would be ideal not to have to edit the templates themselves - is there any way to acheive backwards compatibility via config?


was (Author: tomw1994991):
I think in this case the use case was creating a list of dynamic size (according to the size of another object), which is then populated in  a foreach loop. It would be ideal not to have to edit the templates themselves - is there any way to acheive backwards compatibility via config?

> Number ranges created as ASTIntegerRange$IntegerRange in 2.1 rather than java.util.ArrayList
> --------------------------------------------------------------------------------------------
>
>                 Key: VELOCITY-948
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-948
>             Project: Velocity
>          Issue Type: Bug
>          Components: Engine
>    Affects Versions: 2.1
>            Reporter: Tom White
>            Priority: Minor
>
> Hello!
> I am having issues upgrading from 2.0 to 2.1 with existing templates. The minimal below example illustrates the change in behaviour:
> {code:java}
> <html>
> <body>
> #set ($example= [0..50]) 
> ${example.class.name}   
> #set ($example[10] = 500)
> </body>
> </html>
> {code}
>  
> With 2.0:
> this prints:
> <html><body>java.util.ArrayList</body></html>
> and throws no errors.
>  
> With 2.1:
> this prints:
> <html><body>org.apache.velocity.runtime.parser.node.ASTIntegerRange$IntegerRange</body></html>
> and throws an UnsupportedMethodException at the set line.
>  
> I have tried all kinds of config variables from the docs in a unit test. 
> The 2.1 documentation states:
>  * The VTL RangeOperator [ 1..10 ] and ObjectArray ["a","b"] are {{java.util.ArrayList}} objects when placed in the context or passed to methods. Therefore, your methods that are designed to accept arrays created in the template should be written with this in mind.
> [https://velocity.apache.org/engine/2.1/developer-guide.html] 
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

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