|
View:
New views
11 Messages
—
Rating Filter:
Alert me
|
|
|
BindData with Excludes - how to use it?I'm trying to update bind parameters with a domain class and exclude a property of the domain class that is a Many-Many since I'm only receiving the id of the link from a select list.
I'm trying to use the bindData method with the signature that excludes the property in question, but I keep getting error messages, like it's trying to set it. I found the bindData method here: http://grails.org/Controller+Dynamic+Methods bindData(target, this.params, ['firstName', 'lastName']) // exclude firstName and lastName (since 0.4) Here's my simple domain class: class Grant { Organization organization String projectTitle String grantDescription FocusArea focusArea static belongsTo = Region static hasMany = [regionsServed:Region] BigDecimal amountAwarded int yearAwarded int grantDurationInMonths Status status String toString(){ "${organization.name} - ${projectTitle}" } } And a snippet of my update method: def update = { println params.dump() def grant = Grant.get( params.id ) if(grant) { // Exclude regionsServed bindData(grant, params, ['regionsServed']) I receive this error message. I think it's failing based on the regionsServed parameter. Any idea how I can get the bind to work and exclude regionsServed? I've tried it with regionsServed.id with the same results. Message: No signature of method: static java.util.Set.get() is applicable for argument types: (java.lang.String) values: {"2"} Caused by: groovy.lang.MissingMethodException: No signature of method: static java.util.Set.get() is applicable for argument types: (java.lang.String) values: {"2"} Class: GrantController At Line: [53] Code Snippet: 53: bindData(grant, params, ['regionsServed']) 54: // def region = Regions.get( params.regionsServed.id ) Caused by: groovy.lang.MissingMethodException: No signature of method: static java.util.Set.get() is applicable for argument types: (java.lang.String) values: {"2"} at GrantController$_closure6.doCall(GrantController.groovy:53) at GrantController$_closure6.doCall(GrantController.groovy) |
|
|
Re: BindData with Excludes - how to use it?You're looking at out of date and non-maintained documentation. See the official document at http://grails.org/doc/1.0.x/ and you'll find this example of the correct syntax:
bindData(target, this.params, 'firstName', 'lastName', "author")
|
|
|
Re: BindData with Excludes - how to use it?Hi Brad,
I've tried this to no avail as well. If you look at this link: http://grails.org/doc/1.0.x/guide/6.%20The%20Web%20Layer.html#6.1.6%20Data%20Binding from the docs you reference, there is an explicit example that I believe reflects the way I used it. def sc = new SaveCommand() bindData(sc, params, ['myReadOnlyProp']) Here's the new error message: Message: No signature of method: static java.util.Set.get() is applicable for argument types: (java.lang.String) values: {"1"} Caused by: groovy.lang.MissingMethodException: No signature of method: static java.util.Set.get() is applicable for argument types: (java.lang.String) values: {"1"} Class: GrantController At Line: [53] Code Snippet: 53: bindData(grant, params, 'regionsServed') 54: def region = Region.get( params.regionsServed.id ) I guess if this documentation is as out of date as you suggested and non-maintained -- we should pull it off the site. We should correct it the way it needs to be stated, incorporate the good and get rid of the bad. The bad clearly confuses people. I can't see how to edit the UserGuide at: http://docs.codehaus.org/display/GRAILS/Documentation. I found the Dynamic Method page at: http://docs.codehaus.org/display/GRAILS/Controller+Dynamic+Methods. I'll modify the page accordingly if it's wrong. Can someone tell me definitively how to exclude parameters? Brian
|
|
|
Re: BindData with Excludes - how to use it?Brad, forgot to say thanks.
Also, I do think the list syntax for the properties is more clear than a variable list of attributes. i.e. bindData(target, params, ['exclude1','exclude2'], 'myPrefix') is clearer to me and easier to see that a list of parameters are being excluded than: bindData(target, params, 'exclude1', 'exclude2', "myPrefix") This can be to easily confused with: bindData(target, params, 'exclude1', 'exclude2', 'myPrefix') Brian |
|
|
Re: BindData with Excludes - how to use it?> Message: No signature of method: static java.util.Set.get() is applicable
> for argument types: (java.lang.String) values: {"1"} > Caused by: groovy.lang.MissingMethodException: No signature of method: > static java.util.Set.get() is applicable for argument types: > (java.lang.String) values: {"1"} > Class: GrantController > At Line: [53] > Code Snippet: > 53: bindData(grant, params, 'regionsServed') > 54: def region = Region.get( params.regionsServed.id ) Looks like a bug. Could you attach your stacktrace.log file (in the root of the project) to an e-mail? That will help narrow down what the problem is. Thanks, Peter -- Software Engineer G2One, Inc. http://www.g2one.com/ --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: BindData with Excludes - how to use it?Peter, thanks. I've attached the stack trace. I'll try to look through the code as well. I was using Grails 1.1-SNAPSHOT 82. I recreated the same problem in 1.0.3 using a different example.
Brian stacktrace.log |
|
|
Re: BindData with Excludes - how to use it?> Peter, thanks. I've attached the stack trace. I'll try to look through the
> code as well. I was using Grails 1.1-SNAPSHOT 82. I recreated the same > problem in 1.0.3 using a different example. It looks like GrailsDataBinder processes some fields but fails to take into account the "include" and "exclude" settings. Could you raise an issue please? Thanks, Peter -- Software Engineer G2One, Inc. http://www.g2one.com/ --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: BindData with Excludes - how to use it?Yes I can. Thanks.
Brian
|
|
|
Re: BindData with Excludes - how to use it?Peter, I created: http://jira.codehaus.org/browse/GRAILS-3440
I did some additional research on it and posted it in JIRA. I'm curious what your thoughts are about it. Thanks, Brian |
|
|
Re: BindData with Excludes - how to use it?> I did some additional research on it and posted it in JIRA. I'm curious
> what your thoughts are about it. Thanks Brian. I added a comment in the JIRA (for those not watching the issue). Cheers, Peter -- Software Engineer G2One, Inc. http://www.g2one.com/ --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: BindData with Excludes - how to use it? - RESOLVEDI've figured out what was happening and updated the JIRA. Hopefully it helps someone who ends up having the same issue.
|
| Free Forum Powered by Nabble | Forum Help |