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

Claude Brisson resolved VELOCITY-805.
-------------------------------------
       Resolution: Duplicate
         Assignee: Claude Brisson
    Fix Version/s: 2.1

> Unable to convert instances of two separate enums on a Velocity Template
> ------------------------------------------------------------------------
>
>                 Key: VELOCITY-805
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-805
>             Project: Velocity
>          Issue Type: Bug
>          Components: Engine
>    Affects Versions: 1.7
>         Environment: Tomcat 6, Spring 3.0.4
>            Reporter: Scott
>            Assignee: Claude Brisson
>            Priority: Minor
>             Fix For: 2.1
>
>         Attachments: Test.zip
>
>
> I am unable to utilize the valueOf method on two separate instances of an 
> enum - which share the same name.  The issue is that when the second valueOf 
> method is called, it is invoked on the first enum which is accessed in the 
> template.
> This can be tested by creating two enums with the same name in two separate 
> classes.  Place these onto the context, and then try to utilize the valueOf 
> method and you'll receive a stack trace stating that no value exists.  For 
> example create two separate classes with an inner enum which both have the 
> same name.  Add each enum onto the context, and then in a template attempt to 
> access them in the following way: $enum1.valueOf("VAL1") 
> $enum2.valueOf("SOME_OTHER_VAL").  This will not work.  Luckily you are able 
> to do the following as a workaround: $enum1.valueOf($enum1, "VAL1") 
> $enum2.valueOf($enum2, "SOME_OTHER_VAL")
> Stack trace below:
> java.lang.IllegalArgumentException: No enum const class 
> org.velocity.testing.domain.User$Actions.MODIFY_NAME
>       java.lang.Enum.valueOf(Enum.java:196)
>       org.velocity.testing.domain.User$Actions.valueOf(User.java:1)
>       sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>       
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>       java.lang.reflect.Method.invoke(Method.java:597)
>       
> org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.doInvoke(UberspectImpl.java:395)
>       
> org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:384)
>       
> org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:173)
>       
> org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:280)
>       
> org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:369)
>       
> org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:342)
>       org.apache.velocity.Template.merge(Template.java:356)
>       org.apache.velocity.Template.merge(Template.java:260)
>       
> org.springframework.web.servlet.view.velocity.VelocityLayoutView.renderScreenContent(VelocityLayoutView.java:180)
>       
> org.springframework.web.servlet.view.velocity.VelocityLayoutView.doRender(VelocityLayoutView.java:150)
>       
> org.springframework.web.servlet.view.velocity.VelocityView.renderMergedTemplateModel(VelocityView.java:291)
>       
> org.springframework.web.servlet.view.AbstractTemplateView.renderMergedOutputModel(AbstractTemplateView.java:167)
>       
> org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
>       
> org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047)
>       
> org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817)
>       
> org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
>       
> org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
>       
> org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
>       javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
>       javax.servlet.http.HttpServlet.service(HttpServlet.java:717)



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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

Reply via email to