Announcement Announcement Module
No announcement yet.
Changing Map Value Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Changing Map Value

    Hi guys,

    I was wondering if someone could help me with manipulating values in a Map?

    here's my Person class snippet:

    public class Person{
    public Map<String, Object> getProperties() {
            return properties;
        protected void setProperties(Map<String, Object> propertyMap) {
   = new HashMap(propertyMap);
    The values in this Map get populated by another piece of code, one such key/value pair is:

    key= "riskClass" value= "Standard" (<-- this is the default value)

    I want to be able to update "riskClass"'s value via a jsp using Spring's form tag lib, :
    <form:select path="person[0].properties..<MAGIC CODE GOES HERE TO ACCESS 'riskClass' VALUE>" onchange="profileChange('portfolio', false)">
                        <form:option value="Standard"/>
                        <form:option value="Preferred"/>
    I've searched these forums and the web back to front to find a good example to no avail .

  • #2
    I am pretty sure you can only bind to index'd objects like List and Set.


    • #3
      Please confirm I understand you correctly: you're simply trying to bind the selected value of a drop down to the map "properties" at key "riskClass"?

      Have you tried:
      Without a complete understanding of what your needs are, I can think of a couple better ways of achieving this.


      • #4
        Hi jglynn, thanks for the reply. Yes I've tried that and also:
        but both of them come up with the following exception:

        org.springframework.beans.InvalidPropertyException : Invalid property 'person[0].properties['riskClass']'
        Last edited by jennki; Jan 27th, 2009, 04:29 PM.


        • #5
're simply trying to bind the selected value of a drop down to the map "properties" at key "riskClass"?
          Is correct


          • #6
            hmm... if I use EL:

            I get: 'Standard'

            which is correct.... therefore I can't be mispelling or anything like that :S


            • #7
              Can you shed some light on why you're using a map in this fashion to store/capture a Person's properties?

              At first glance, I would suggest creating a class to capture these properties at which point you could simply bind to something like: person[0].properties.riskClass


              • #8
                The reason why we've decided to store properties into a hashmap is because we have a rule engine that populates this hashmap with values we need to request depending on what product this person applies for. The rule engine is updated by an administrator via a seperate app. We want to keep the properties dynamic so that the administrator can add in new fields to request along with a particular rule without us having to change the base structure of the Person and Product objects.