My Grails app has the following command object
class MyCommand {
@BindUsing({
obj, source ->
User.findByUsername(source.username)
})
User user
// other stuff not relevant to this question
}
The request parameters includes a username which uniquely identifies the User. I've added the @BindUsing annotation in order to bind the user property of the command object to the corresponding User instance. However, after databinding has completed, the user field is null, even though the username parameter is correct. What am I doing wrong?
I don't think this has anything to do with retention policy, dynamic finders, withTransaction or withSession. The issue is that the @BindUsing closure is only triggered for the "user" property if there is a request parameter named "user". The description suggests that there probably isn't one in play in this scenario.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With