Announcement Announcement Module
Collapse
No announcement yet.
Enum constants in webflow expression language? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Enum constants in webflow expression language?

    Hi.

    Is it possible to use enum constant values in the web flow expression language?
    I would like to use something like this:

    Code:
    <evaluate expression="myVariable.myMethod(mypackage.MyClass.MyEnum.HELLO_WORLD)" />
    This does not seem to work for me. Says it cannot be resolved.

    So I am wondering, is this possible? Or what am I doing wrong?

    Thank you!

  • #2
    If you're using OGNL for your expression parser, there's a special way to invoke this.

    The pattern is:

    @package.name.enum.class.name@ENUM_NAME

    So, for your case, you would use:
    @mypackage.MyClass.MyEnum@HELLO_WORLD

    Not sure how to do this with other expression parsers, though.

    Comment


    • #3
      Use T to access a type and $ to access an inner type

      To do this in Spring EL, you would use:

      Code:
      T(mypackage.MyClass$MyEnum).HELLO_WORLD
      Using "$" to access an inner type isn't in the reference docs, I just figured it out using JUnit and some inspired guesswork.

      Comment


      • #4
        Thanks for the response, Andrew. I was stuck on this as well and the example you provided solved my problem.

        Comment


        • #5
          Glad to be of help!

          Comment

          Working...
          X