Grails rendering JSON from domain list weird behaviour -
i'm trying homecoming json controller action. action method
import grails.converters.json .... def getdoctorlist(id){ def serviceno = id ?: "1" def service = servicepoint.findbynumber(serviceno) def jsonmap=service?.staff.collect{ [id: it.id , name: it.firstname +" "+ it.lastname] } render jsonmap json }
if convert jsonmap json in lastly line page not rendered , if removed json page rendered , works fine. wrong code?
=================================================================================
i don't need render gsp page need render map json utilize in filling drop box in gsp page. pages rendered ajax not shown when utilize (as json) in code. if remove works fine.
by rendering json, you're not rendering template associated action. if assume convention , have getdoctorlist.gsp, next work:
def getdoctorlist(id){ //.. logic here // leaving no render method default convention // rendering getdoctorlist.gsp } def getdoctorlist(id){ //.. logic here // supplying render view render view render view: 'doctor_list' // assumes doctor_list.gsp } def getdoctorlist(id){ //.. logic here // rendering json not utilize template @ render jsonmap json }
this work, uncertainty want:
def getdoctorlist(id){ //.. logic here [jsonmap: jsonmap json] }
that force jsonmap request param getdoctorlist.gsp. speaking, rendering json info in response ajax request.
json grails
No comments:
Post a Comment