grails - Why values of list is changing while sending to a service -
i new grails , developing web application.
i have list of long values getting ids of domain class objects.
initially list [1,2,3]. need use list of values in service class saving associations.
but same list getting in service class [49,50,51]
why difference of 48 occurred? , how can list same sent.
controller class:
def createquestion(createquestioncommand createquestioncmd) { if( createquestioncmd.haserrors() ) { render(view:"create_question", model:[createquestioncmd:createquestioncmd , tags:tag.list()]) } else { question question = new question() question.title=createquestioncmd.title question.description=createquestioncmd.description list tags= createquestioncmd.tags question = questionservice.create(question,tags) render(view: "question_submitted") } }
service class:
def create(question question, list<long> tagid) { list<tag> taglist=gettagsbyid(tagid) question.save( failonerror:true ) iterator itr=taglist.iterator(); while(itr.hasnext()) { tag tag=itr.next() question.addtotags(tag).save() } } def gettagsbyid(list tagid){ iterator itr=tagid.iterator(); list<tag> tags while(itr.hasnext()) { long id=itr.next() println "value of id : " println id println id.getclass().getname() tag tag=tag.findbyid(id) tags.add(tag) } return tags }
createquestioncmd.tags list<string>
, trying place list<long>
Comments
Post a Comment