Announcement Announcement Module
Collapse
No announcement yet.
Binding form parameters on bean with collection property Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Binding form parameters on bean with collection property

    I'm using a SimpleFormController with a bean that has a collection property. Consider for example a orders property (a List of Orders), on a Customer bean. Is it possible to bind the parameters on the nested Order bean using the standard property paths as request parameter names?

    In other words, will a form parameter name like
    Code:
    customer.order[0].productId
    result in a call like
    Code:
    customer.getOrder().get(0).setProductId
    What is the best approach here?
    Thanks!

  • #2
    Take a look at:

    http://opensource.atlassian.com/proj.../browse/SPR-52

    Comment


    • #3
      Ok, thanks, this helped! I'm trying it out right now.

      Just out of curiosity, this seems to be implemented at the bind jsp tag level. I'm wondering wether a setProperty() on the BeanWrapper with a path like this would also work. So let's say
      Code:
      BeanWrapper bw = (...);
      bw.setProperty("person.addresses[2].street", "");

      Comment


      • #4
        For the equally curious: my example above
        Code:
        BeanWrapper bw = (...); 
        bw.setProperty("person.addresses[2].street", "NY Blvd");
        works perfectly on both Arrays and Lists (ArrayLists). Cool.

        Comment

        Working...
        X