Announcement Announcement Module
Collapse
No announcement yet.
Injecting an enum value into a util:map Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Injecting an enum value into a util:map

    Hi, I'm quite new to Spring. I have the following which results in an error

    public enum AppParameters {ORGANISATION, DESCRIPTION, STATUS}

    public enum AppStatuses {LIVE, PRELIVE}

    <util:map id="myMap" key-type="AppParameters">
    <entry key="ORGANISATION" value="AnOrg" />
    <entry key="DESCRIPTION" value="ADescription" />
    <entry key="STATUS" value="AppStatuses.LIVE" />
    </util:map>

    This result in a ClassCastException because AppStatuses.LIVE is being treated as a String.

    WARNING: java.lang.String cannot be cast to AppStatuses

    Replacing the "value" with "ref" results in a Sax error, Attribute ref is not allowed to appear in element 'entry'

    I want to inject an AppStatuses enum into the STATUS value on myMap. How can I achieve this?

    Thanks
    Ben

  • #2
    Originally posted by benboxer View Post
    Replacing the "value" with "ref" results in a Sax error, Attribute ref is not allowed to appear in element 'entry'
    Not quite sure but wasn't it "value-ref"? I don't have the code to hand where I used it.

    Joerg

    Comment


    • #3
      OK, many thanks. I've used value-ref which seems to have solved the issue.

      Comment

      Working...
      X