Results 1 to 3 of 3

Thread: Injecting an enum value into a util:map

  1. #1
    Join Date
    Sep 2007
    Posts
    2

    Default 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. #2
    Join Date
    Nov 2005
    Location
    Reutlingen, Germany
    Posts
    2,098

    Default

    Quote 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
    This post can contain insufficient information.

  3. #3
    Join Date
    Sep 2007
    Posts
    2

    Default

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •