JQuery EasyUI from Grails

  • Tags: jquery
  • Latest: 1.7
  • Last Updated: 08 April 2014
  • Grails version: 2.0 > *
  • Authors: Leandro Gehlen
0 vote
Dependency:
compile ":easyui:1.7"

 Documentation  Source  Issues

Summary

Supplies jQuery EasyUI resources and taglibs. Depends on jQuery EasyUI plugin. See http://www.jeasyui.com/

Installation

grails install-plugin easyui

Description

Grails EasyUI Plugin helps you to develop rich applications using the jQuery JavaScript library EasyUI framework.

The plugin implements taglibs for writing the compontentes in gsp, plus the scripts to generate scaffold to produce CRUD quick and powerful.

Another feature created is EasyuiDomainClassMarshaller that simplifies the rendering of domain objects to JSON-compatible components JQuery EasyUI.

Including the resources

You must use the Grails resources framework to make use of this plugin.

Download http://www.jeasyui.com/download, extract content in webapp/js/jquery-easyui

jquery-easyui - jQuery EasyUI framework (version 1.3.2)

Configuration

The following settings are available

// available "en", "pt_BR" 
grails.plugin.easyui.locale = 'en'
//folder name found in "jquery-easyui/themes"
grails.plugin.easyui.theme = 'black'
//version defined in the file "jquery-1.8.0.min.js" found in "jquery-easyui"
grails.plugin.easyui.jquery.version = '1.8.0'

TagLibs

<r:require modules="easyui_core"/>
<r:layoutResources />

Hello World!

<html>
  <head>
    <title>Hello World Demo</title>
    <r:require module="easyui_core"/>    			
    <r:layoutResources />
  </head>
<body>
  <e:window title="My Window" width="300px" height="100px">
    Some Content.
  </e:window>
</body>
</html>

Scaffold

We can generate scaffold with commands:
grails easyui-generate-controller [domainClass]
grails easyui-generate-view [domainClass]
grails easyui-generate-all [domainClass]
grails easyui-install-templates

Registering DomainClassMarshaller

To integrate the data with the components you need to register the domain class renderer. To register this class it is necessary to change the file BootStrap.groovy as follows:

import grails.converters.JSON
import org.codehaus.groovy.grails.commons.GrailsApplication
import org.grails.plugins.easyui.EasyuiDomainClassMarshaller
…
class BootStrap {
    GrailsApplication grailsApplication
    def init = { servletContext ->    	 
        JSON.registerObjectMarshaller(new EasyuiDomainClassMarshaller(true, grailsApplication))
        …
    }
    …
}