Announcement Announcement Module
Collapse
No announcement yet.
Binding to map properties Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Binding to map properties

    I was reading this thread:
    http://forum.springframework.com/vie...5ed6072806aaeb

    and almost posted an answer I thought would work, but I tried it out, and was surprised it didn't.

    I figured you could bind map properties just like normal properties using the map propertyname spec: "attributes[key]". Doesn't work. I want to do:


    Code:
    public class Foo {
         private Map m_attributes = new HashMap();
       
         public Foo() {
                       m_attributes.put("myprop", "myvalue");
         }
    }
    
    ...
    SwingFormModel swingFormModel = SwingFormModel.createFormModel(new Foo(), true);
    ...
    swingFormModel.createBoundControl("attributes[myprop]");
    I should get a control that edits a string. I was suprised it didn't work, because this works:
    Code:
                BeanWrapperImpl beanWrapper = new BeanWrapperImpl();
                beanWrapper.setWrappedInstance(new Foo());
                beanWrapper.setPropertyValue("attributes[foo]", new String("hello"));
    The problem lies in the BeanPropertyAccessStrategy
    1) Not using the BeanWrapper to correctly get the type
    2) SwingFormModel (and others) not consistently asking just the BeanPropertyAccessStrategy for the type of a propertyName (sometimes it uses some ClassUtils stuff).

    I've got a patch in progress, but I was wondering how to submit, because the changes are both in spring sandbox and springrc.

    Thanks

  • #2
    Submit them to JIRA - when you do please be sure to clearly document the feature and what the expected behaivior should be.

    Thanks!
    Keith

    Comment

    Working...
    X