天天看點

在Grails中應用ExtjsThis plugin is discontinued by it's author due to the ExtJS license fiasco emerged recently.Plugin version history

This plugin is discontinued by it's author due to the ExtJS license fiasco emerged recently.

This plugin provides integration with the Ext JavaScript Library. When installing the plugin, it downloads and installs automatically the latest Ext 2.0.2 distribution in your application, and registers itself to be used with the adapative AJAX tags. It also contains two helper tags to easily include additional Ext javascript and css files as well.

Installation

To install the Ext plugin type this command from your project's root folder:

grails install-plugin ext
      

The complete Ext distribution is downloaded and installed under your project's \web-app\js\ext\2.0.2 folder.

Usage

To use Grails' adaptive AJAX support just add the folowing line in the head section:

<g:javascript library="ext" />
      

If you want to include additional Ext javascript and css files include them using:

<ext:javascript dir="build/widgets" file="MessageBox-min.js" />
<ext:javascript dir="build/widgets" file="MessageBox-min.js" version="2.0.1" /> 
// version to be used in case multiple version installed
<ext:stylesheet dir="resources/css" file="ext-all.css" />
      

Overriding default javascript files

By default ext-base.js and ext-core.js are included when using <g:javascript library="ext" />. Adding additional libraries to the default list can be done in a BootStrap class:

import org.codehaus.groovy.grails.plugins.web.taglib.JavascriptTagLib

class BootStrap {
    def init = { servletContext ->
        JavascriptTagLib.LIBRARY_MAPPINGS.ext += ["ext/2.0.2/build/widgets/MessageBox-min", ..]
    }
    def destroy = {
    }
}
      

It's also possible to replace all default included javascript libraries. For example if you want to use ext-all.js instead of ext-core.js. Just incorporate the following into your BootStrap.

import grails.util.GrailsUtil
import org.codehaus.groovy.grails.plugins.web.taglib.JavascriptTagLib

class BootStrap {
    def init = { servletContext ->
        JavascriptTagLib.LIBRARY_MAPPINGS.ext = ["ext/2.0.2/adapter/ext/ext-base", "ext/2.0.2/ext-all"]
    }
    def destroy = {
    }
}
      

If you want to include debug versions of the included javascript files in your development environment, do something like:

import grails.util.GrailsUtil
import org.codehaus.groovy.grails.plugins.web.taglib.JavascriptTagLib

class BootStrap {
    def init = { servletContext ->
        if (GrailsUtil.isDevelopmentEnv()) {
            JavascriptTagLib.LIBRARY_MAPPINGS.ext = ["ext/2.0.2/adapter/ext/ext-base", "ext/$2.0.2/ext-core-debug"]
        }
    }
    def destroy = {
    }
}
      

Upgrading

If you want to upgrade:

  • Delete the plugin from the project's plugins folder
  • (Optional) Delete the previous Ext version folder from web-appjsext
  • Re-install the plugin by executing grails install-plugin ext

Plugin version history

Discontinued (May 27, 2008)

2.0.2 (April 1, 2008)

  • First release of the plugin