posts - 431,  comments - 344,  trackbacks - 0
公告
 Don't Repeat Yourself
座右铭:you can lose your money, you can spent all of it, and if you work hard you get it all back. But if you waste your time, you're never gonna get it back.
公告本博客在此声明部分文章为转摘,只做资料收集使用。


微信: szhourui
QQ:109450684
Email
lsi.zhourui@gmail.com
<2008年7月>
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

留言簿(15)

随笔分类(1019)

文章分类(3)

文章档案(21)

收藏夹

Link

好友博客

最新随笔

搜索

  •  

积分与排名

  • 积分 - 855853
  • 排名 - 47

最新评论

阅读排行榜

This plugin provides integration with the Yahoo! UI Library. When installing the plugin, it downloads and installs automatically the latest YUI 2.5.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 YUI javascript and css files as well.

Installation

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

grails install-plugin yui
The complete YUI distribution is downloaded and installed under your project's web-appjsyui2.5.2 folder.

Usage

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

<g:javascript library="yui" />
If you want to include additional YUI javascript and css files include them using:
<yui:javascript dir="calendar" file="calendar-min.js" />
<yui:javascript dir="calendar" file="calendar-min.js" version="2.5.2" />
// version to be used in case multiple version installed
<yui:stylesheet dir="calendar/assets" file="calendar.css" />
Refer to the Ajax section of the Grails reference documentation for usage.

Overriding default javascript files

By default only yahoo-dom-event.js and connection-min.js are included when using <g:javascript library="yui" />. 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.yui += ["yui/2.5.2/calendar/calendar-min", "yui/2.5.2/container/container-min"] } def destroy = { } }

It's also possible to replace all default included javascript libraries. For example if you want to use the YUI debug javascript files in development mode:
import grails.util.GrailsUtil
import org.codehaus.groovy.grails.plugins.web.taglib.JavascriptTagLib

class BootStrap { def init = { servletContext -> if (GrailsUtil.isDevelopmentEnv()) { JavascriptTagLib.LIBRARY_MAPPINGS.yui = ["yui/2.5.2/yahoo/yahoo-debug", "yui/2.5.2/dom/dom-debug", "yui/2.5.2/event/event-debug", "yui/2.5.2/connection/connection-debug"] } } def destroy = { } }

Serving YUI Files from Yahoo! Servers

It's also possible to serve the javascript from the Yahoo! servers. First delete the yui folder from web-appjs after installing the plugin. Then, in a BootStrap class, override the mapping which contains the javascript files to include by default:

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

class BootStrap { def init = { servletContext -> JavascriptTagLib.LIBRARY_MAPPINGS.yui = [] } def destroy = { } }

The only drawback is that you need to include the references to the javascript files manually. Probably the easiest way is to do this in the main.gsp layout.

Upgrading

If you want to upgrade:

  • Delete the plugin from the project's plugins folder
  • (Optional) Delete the previous YUI version folder from web-appjsyui
  • Re-install the plugin by executing grails install-plugin yui
posted on 2008-07-29 22:38 周锐 阅读(522) 评论(0)  编辑  收藏 所属分类: Groovy&Grails

只有注册用户登录后才能发表评论。


网站导航: