Skip to content

Grails’ RemoteFunction Tag

I’ve had to dig for the correct way to use this a few times now, so I am putting it here as a keepsake:


<bean:withBean beanName="page1Command">
    <bean:field property="postcode"/>
    <bean:select property="businessType"/>
    <bean:field property="campaignStart" precision="month"/>
    <bean:field property="campaignEnd" precision="month"/>
    <bean:select property="campaignSize" from="${Constants.CAMPAIGNSIZES}"
            noSelection="['':'Choose the Campaign Size']"
            onchange="${remoteFunction(action:'ajaxCampaign',params:'\'campaignSize=\'+escape(this.value)+\'&postcode=\'+this.form.postcode.value',onFailure:'handleFailure(e);',onSuccess:'updateCampaignSizes(e);')}"/>
</bean:withBean>

The tricky bit (although it doesn’t look like it) is getting multiple parameters passed through successfully. Always gives me trouble. Other people too.

PS: Kudos to Marc Palmer for his Bean-Fields Plugin (shown above). A real time-saver.

Java Enterprise Edition, JEE, JavaServer Pages, JSP, Tag Libraries, Servlets, Enterprise Java Beans, EJB, Java Messaging Service JMS, BEA Weblogic, JBoss, Application Servers, Spring Framework, Groovy, Grails, Griffon, Seam, Open Source, Service Oriented Architectures, SOA, Java 2 Standard Edition, J2SE