Search code examples
ajaxgrailsgspgrails-domain-classgrails-controller

using <g:select remoteFunction> grails


I have general question regarding using remoteFunction. I am using the like

i am making call to controller. I want to update a textbox based on the object from controller.

<g:fieldValue bean="${ProfileDomainInstance}" field="profileDescription" id="profileDescription"/> 

how can i return profileDoaminInstance object from controller so that i can use that in my GSP.profilenames are comin from different object . I tried to send it as regular model.

def getProfileDescription(){
        println("came here")
        println(params?.profileName)
.
.
.
        [ProfileDomainInstance:ProfileDomainInstance])
    }

how can i send this object to gsp. I also tried to render the view. It was still not working.


Solution

  • create template for your profileDescription and use render on your controller to render it

    so your code will be something like this

    def getProfileDescription(){
            println("came here")
            println(params?.profileName)
    .
    .
    .
    render(template:"/profileDescriptionTemplate", model:[ProfileDomainInstance:ProfileDomainInstance ] )
    
           )
    
    
    <div id='divForprofileDescription'>
    <g:render template="profileDescriptionTemplate" model="['ProfileDomainInstance':ProfileDomainInstance]" /> 
    </div>
    
    
    <g:select from='${ProfileList?.profileName}' name= 'ProfileSelect' id='ProfileSelect' noSelection="['null':' SELECT Profile']" disabled="true" onChange="${remoteFunction(action:'getProfileDescription', params: '\'profileName=\' + this.value',update:[success:'divForprofileDescription'])}
        }