1

I'm trying to bind a Set of objects to my Grails Command Objects, but currently, it doesn't work an throws errors:

Field error in object 'NewPersonCommand' on field 'addresses': rejected value [[Ljava.lang.String;@6d64b5fb]; codes [NewPersonCommand.addresses.typeMismatch.error,NewPersonCommand.addresses.typeMismatch,newPersonCommand.addresses.typeMismatch.error,newPersonCommand.addresses.typeMismatch,typeMismatch.NewPersonCommand.addresses,typeMismatch.addresses,typeMismatch.java.util.Set,typeMismatch]; arguments [addresses]; default message [Could not find matching constructor for: Address(java.lang.String)]>

I have the following command object in my Grails application:

class NewPersonCommand {
    String name

    Set<Address> addresses
}

And the code for the form I'm posting looks like this:

 <input type="hidden" name="addresses" value="1" />
 <input type="hidden" name="addresses" value="4" />
 <input type="hidden" name="addresses" value="18" />

Any idea how I can fix this, so I can bind my set of addresses to the command object?

Erik Pragt
  • 13,513
  • 11
  • 58
  • 64
  • If you file a JIRA and attach a simple sample app I will take a look at it this week. – Jeff Scott Brown Aug 18 '14 at 01:18
  • can you include the `Address` class? there seems to be a missing constructor. – tmarthal Aug 18 '14 at 04:52
  • @JeffScottBrown I've created an issue here: https://jira.grails.org/browse/GRAILS-11666. If this is not enough, I can create a simple sample application. – Erik Pragt Aug 18 '14 at 09:01
  • @tmarthal The address looks like: class Address {}. Yes, it looks like it's missing a constructor, but I think there's something wrong with the databinding. There shouldn't be a need for the missing constructor. – Erik Pragt Aug 18 '14 at 09:14
  • @tmarthal The `Address` class does not need to have a constructor defined. The default no-arg constructor is fine. The behavior described here is a bug. The binder is not supposed to be invoking the constructor. The binder is supposed to be retrieving instances from the data store using `Address.get(...)`. – Jeff Scott Brown Aug 18 '14 at 13:38
  • I think I fixed https://jira.grails.org/browse/GRAILS-11666 this morning. Thanks for the feedback. – Jeff Scott Brown Aug 18 '14 at 14:58

0 Answers0