Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable save multi select box value into database using Grails and groovy

 
raghuram edadala
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am using mysql database. I want save the multi select box value into database. I am getting exception while saving the record. Here I am sending my domain, controller and select box code. please help in this..

My domain class is
package com.tag.masters
import com.tag.User
class UserRoleMap {
static hasMany = [roles:UserRole]
User users
UserRole roles
User createdBy
Date createdDt
User updatedBy
static constraints = {
users nullable:false, unique:true
createdBy nullable:true
createdDt nullable:true
updatedBy nullable:true
}
static mapping = {
id column:'rolemap_id'
}
}
-------------------------------------------------------------
and my multi select box is
<p>
<label>Roles</label>
<span class="field">
<g:select id="roles" name="roles.id" from="${com.tag.masters.UserRole.list()}" optionValue="roleName" optionKey="id" value="${userRoleMapInstance?.roles?.id}" multiple="true" noSelection="['null': '']"/>
</span>
</p>
--------------------------------------------------------------
this is my controller method
def employeeRoleMap(){
[userRoleMapInstance: new UserRoleMap(params)]
}
def employeeRoleMapSave(){
System.out.println("-------------roles-- "+params.roles);
def userRoleMapInstance = new UserRoleMap(params)
userRoleMapInstance.save(flush:true,failOnError:true)
def userRoleMapInstanceList = UserRoleMap.findAll()
render userRoleMapInstanceList as JSON
}
---------------------------------------------------------------
Error 500: Internal Server Error

URI
/corpportal/tagportal/employeeRoleMap
Class
groovy.lang.MissingMethodException
Message
No signature of method: com.tag.masters.UserRole.get() is applicable for argument types: (java.lang.String, java.lang.String) values: [1, 3] Possible solutions: get(java.io.Serializable), getId(), grep(), getAt(java.lang.String), wait(), getAll()

Around line 429 of grails-app\controllers\tagportal\TagportalController.groovy

426: }
427:
428:
def employeeRoleMap(){
429: [userRoleMapInstance: new UserRoleMap(params)]
430: }
431: def employeeRoleMapSave(){
432: System.out.println("-------------roles-- "+params.roles);

Around line 195 of PageFragmentCachingFilter.java

192: if (CollectionUtils.isEmpty(cacheOperations)) {
193: log.debug("No cacheable annotation found for {}:{} {}",
194: new Object[] { request.getMethod(), request.getRequestURI(), getContext() });
195: chain.doFilter(request, response);196: return;
197: }
198:

Around line 63 of AbstractFilter.java

60: try {
61: // NO_FILTER set for RequestDispatcher forwards to avoid double gzipping62: if (filterNotDisabled(request)) {
63: doFilter(request, response, chain);
64: }
65: else {
66: chain.doFilter(req, res);

Trace

Line | Method
->> 97 | methodMissing in org.grails.datastore.gorm.GormStaticApi
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 429 | employeeRoleMap in TagportalController.groovy
| 195 | doFilter . . . in PageFragmentCachingFilter.java
| 63 | doFilter in AbstractFilter.java
| 886 | runTask . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
| 908 | run in ''
^ 662 | run . . . . . . in java.lang.Thread
for single selection it will work, but when i select more than one value it is thrown above exception. please help in this.
thanks in advance
raghu
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic