在Grails中应用Extjs

本文介绍了一款已停用的Grails插件,该插件用于将ExtJS JavaScript库集成到Grails应用中。安装插件后,可以自动下载并安装ExtJS库,并通过自适应AJAX标签进行使用。此外,还提供了两个辅助标签来轻松包含额外的ExtJS JavaScript和CSS文件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值