You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Asmodean (JIRA)" <de...@velocity.apache.org> on 2007/04/11 10:42:32 UTC

[jira] Created: (VELOCITY-538) Cannot add objects as values in Map creation unless last entry is quoted

Cannot add objects as values in Map creation unless last entry is quoted
------------------------------------------------------------------------

                 Key: VELOCITY-538
                 URL: https://issues.apache.org/jira/browse/VELOCITY-538
             Project: Velocity
          Issue Type: Bug
          Components: Engine
    Affects Versions: 1.5
         Environment: Windows XP Service pack 2, Sun JVM 1.5.0.11
            Reporter: Asmodean
            Priority: Minor


When creating a Map using the velocity 1.5 syntax ({key:value,...}) it seems I can only add objects (except Strings) as map values if the last map entry is quoted. The following (where $object is put into context before, of course) will produce a parse exception:

#set ($map = {"key": $object})

Where the following will not:

#set ($map = {"key": $object, "anotherkey":"anothervalue"})

The "anotherkey": "anothervalue" entry does the trick in the form of "":"" as well, but something is up here. OR this is a map creation "flaw" not documented. Using the following will of course not get the desired result:

#set ($map = {"key": "$object"})

since velocity will evaluate the $object reference and use its .toString() (where what you wanted to do was probably to add the actual object).

Would appreciate comments that could indicate if my thinking here is flawed or if it actually is a bug. 

-- 
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


[jira] Updated: (VELOCITY-538) Cannot add objects as values in Map creation unless last entry is quoted

Posted by "Will Glass-Husain (JIRA)" <de...@velocity.apache.org>.
     [ https://issues.apache.org/jira/browse/VELOCITY-538?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Will Glass-Husain updated VELOCITY-538:
---------------------------------------

    Fix Version/s: 1.6

thanks for reporting this. seems like a bug to me.

> Cannot add objects as values in Map creation unless last entry is quoted
> ------------------------------------------------------------------------
>
>                 Key: VELOCITY-538
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-538
>             Project: Velocity
>          Issue Type: Bug
>          Components: Engine
>    Affects Versions: 1.5
>         Environment: Windows XP Service pack 2, Sun JVM 1.5.0.11
>            Reporter: Asmodean
>            Priority: Minor
>             Fix For: 1.6
>
>
> When creating a Map using the velocity 1.5 syntax ({key:value,...}) it seems I can only add objects (except Strings) as map values if the last map entry is quoted. The following (where $object is put into context before, of course) will produce a parse exception:
> #set ($map = {"key": $object})
> Where the following will not:
> #set ($map = {"key": $object, "anotherkey":"anothervalue"})
> The "anotherkey": "anothervalue" entry does the trick in the form of "":"" as well, but something is up here. OR this is a map creation "flaw" not documented. Using the following will of course not get the desired result:
> #set ($map = {"key": "$object"})
> since velocity will evaluate the $object reference and use its .toString() (where what you wanted to do was probably to add the actual object).
> Would appreciate comments that could indicate if my thinking here is flawed or if it actually is a bug. 

-- 
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


[jira] Assigned: (VELOCITY-538) Cannot add objects as values in Map creation unless last entry is quoted

Posted by "Will Glass-Husain (JIRA)" <de...@velocity.apache.org>.
     [ https://issues.apache.org/jira/browse/VELOCITY-538?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Will Glass-Husain reassigned VELOCITY-538:
------------------------------------------

    Assignee: Will Glass-Husain

> Cannot add objects as values in Map creation unless last entry is quoted
> ------------------------------------------------------------------------
>
>                 Key: VELOCITY-538
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-538
>             Project: Velocity
>          Issue Type: Bug
>          Components: Engine
>    Affects Versions: 1.5
>         Environment: Windows XP Service pack 2, Sun JVM 1.5.0.11
>            Reporter: Asmodean
>            Assignee: Will Glass-Husain
>            Priority: Minor
>             Fix For: 1.6
>
>
> When creating a Map using the velocity 1.5 syntax ({key:value,...}) it seems I can only add objects (except Strings) as map values if the last map entry is quoted. The following (where $object is put into context before, of course) will produce a parse exception:
> #set ($map = {"key": $object})
> Where the following will not:
> #set ($map = {"key": $object, "anotherkey":"anothervalue"})
> The "anotherkey": "anothervalue" entry does the trick in the form of "":"" as well, but something is up here. OR this is a map creation "flaw" not documented. Using the following will of course not get the desired result:
> #set ($map = {"key": "$object"})
> since velocity will evaluate the $object reference and use its .toString() (where what you wanted to do was probably to add the actual object).
> Would appreciate comments that could indicate if my thinking here is flawed or if it actually is a bug. 

-- 
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


[jira] Resolved: (VELOCITY-538) Cannot add objects as values in Map creation unless last entry is quoted

Posted by "Will Glass-Husain (JIRA)" <de...@velocity.apache.org>.
     [ https://issues.apache.org/jira/browse/VELOCITY-538?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Will Glass-Husain resolved VELOCITY-538.
----------------------------------------

    Resolution: Fixed

Fixed.  Added syntax to test/templates/map.vm for automatic testing.

> Cannot add objects as values in Map creation unless last entry is quoted
> ------------------------------------------------------------------------
>
>                 Key: VELOCITY-538
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-538
>             Project: Velocity
>          Issue Type: Bug
>          Components: Engine
>    Affects Versions: 1.5
>         Environment: Windows XP Service pack 2, Sun JVM 1.5.0.11
>            Reporter: Asmodean
>            Assignee: Will Glass-Husain
>            Priority: Minor
>             Fix For: 1.6
>
>
> When creating a Map using the velocity 1.5 syntax ({key:value,...}) it seems I can only add objects (except Strings) as map values if the last map entry is quoted. The following (where $object is put into context before, of course) will produce a parse exception:
> #set ($map = {"key": $object})
> Where the following will not:
> #set ($map = {"key": $object, "anotherkey":"anothervalue"})
> The "anotherkey": "anothervalue" entry does the trick in the form of "":"" as well, but something is up here. OR this is a map creation "flaw" not documented. Using the following will of course not get the desired result:
> #set ($map = {"key": "$object"})
> since velocity will evaluate the $object reference and use its .toString() (where what you wanted to do was probably to add the actual object).
> Would appreciate comments that could indicate if my thinking here is flawed or if it actually is a bug. 

-- 
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


[jira] Commented: (VELOCITY-538) Cannot add objects as values in Map creation unless last entry is quoted

Posted by "Will Glass-Husain (JIRA)" <de...@velocity.apache.org>.
    [ https://issues.apache.org/jira/browse/VELOCITY-538?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12504287 ] 

Will Glass-Husain commented on VELOCITY-538:
--------------------------------------------

More detail.  The problem is the } character right after the $object.

This doesn't work (parse error)
#set ($map = {"key": $object})

and this does (note the spacing)

#set ($map = {"key": $object    })

> Cannot add objects as values in Map creation unless last entry is quoted
> ------------------------------------------------------------------------
>
>                 Key: VELOCITY-538
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-538
>             Project: Velocity
>          Issue Type: Bug
>          Components: Engine
>    Affects Versions: 1.5
>         Environment: Windows XP Service pack 2, Sun JVM 1.5.0.11
>            Reporter: Asmodean
>            Priority: Minor
>             Fix For: 1.6
>
>
> When creating a Map using the velocity 1.5 syntax ({key:value,...}) it seems I can only add objects (except Strings) as map values if the last map entry is quoted. The following (where $object is put into context before, of course) will produce a parse exception:
> #set ($map = {"key": $object})
> Where the following will not:
> #set ($map = {"key": $object, "anotherkey":"anothervalue"})
> The "anotherkey": "anothervalue" entry does the trick in the form of "":"" as well, but something is up here. OR this is a map creation "flaw" not documented. Using the following will of course not get the desired result:
> #set ($map = {"key": "$object"})
> since velocity will evaluate the $object reference and use its .toString() (where what you wanted to do was probably to add the actual object).
> Would appreciate comments that could indicate if my thinking here is flawed or if it actually is a bug. 

-- 
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