在Grails中应用Extjs

来源:互联网 发布:手机有网络微信不能用 编辑:程序博客网 时间:2024/05/17 23:39

This plugin is discontinued byit's author due to the ExtJS license fiasco emergedrecently.

 

This plugin provides integration with the ExtJavaScript Library. When installing the plugin, it downloads andinstalls automatically the latest Ext 2.0.2 distribution in yourapplication, and registers itself to be used with the adapativeAJAX tags. It also contains two helper tags to easily includeadditional Ext javascript and css files as well.

Installation

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

 

grails install-plugin ext

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

Usage

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

 

<g:javascript library="ext" />

If you want to include additional Extjavascript 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 areincluded when using <g:javascript library="ext"/>. Adding additional libraries to the default listcan 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 defaultincluded javascript libraries. For example if you want to useext-all.js instead of ext-core.js. Just incorporate the followinginto your BootStrap.

 

import grails.util.GrailsUtilimport 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 theincluded javascript files in your development environment, dosomething like:

 

import grails.util.GrailsUtilimport 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 fromweb-appjsext
  • Re-install the plugin by executing grails install-pluginext

Plugin version history

Discontinued (May 27, 2008)

2.0.2 (April 1, 2008)

  • First release of the plugin
原创粉丝点击