Login required
Download

Dojo 1.7.1 for Grails

(10)
Author(s) Rob Meidal
Current Release 1.7.1.5   (4 days ago)
Grails Version 1.3.0 > *
Tags ajax  calendar  dojo  editors  grid  javascript  paginate  remote pagination  rich client  tree 
Dependency
compile ":dojo:1.7.1.5"
The Dojo Plugin adds the Dojo toolkit to your application. This javascript library provides a complete collection of user interface controls, giving you the power to create web applications that are highly optimized for usability, performance, internationalization, accessibility, but above all deliver an incredible user experience. This plugin provides full support for <g:formRemote>, <g:remoteField>, <g:remoteFunction>, <g:remoteLink> and <g:submitToRemote>.

Also adds these two tags: <dojo:paginate> and <dojo:sortableColumn>. These do the same thing that the grails versions of the tags but will do them via ajax calls.

Adds these convenient widget tags: <dojo:header>, <dojo:require>, <dojo:css>, <dojo:grid> (<dojo:col>, <dojo:bind>), <dojo:dataSourceView> (<dojo:nodeTemplate>, <dojo:nodeDefaultTemplate>), <dojo:popOver> (<dojo:popOverContent>, <dojo:closePopOver>), <dojo:frame> (<dojo:frameLink> <dojo:onload>), <dojo:tree> (<dojo:treeNode>, <dojo:treeLeaf>), <dojo:help>, <dojo:toolip>, <dojo:editor>, <dojo:datePicker>, <dojo:timePicker>, <dojo:dateTimePicker>, <dojo:numberPicker>

For more information about the Dojo Toolkit please visit http://www.dojotoolkit.org/.

Last updated by cfxram 1 week ago
To install the latest version of the dojo plugin (Dojo 1.7.1):
grails install-plugin dojo

To install the 1.6.1 version of Dojo:

grails install-plugin dojo 1.6.1.4

Targets:

grails install-custom-dojo

  • This target will build an optimized version of dojo that is tailored to your application. Read the FAQ for more information.
Last updated by cfxram 4 days ago

Installation

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

grails install-plugin dojo

The base dojo file will automatically be included in your application under web-apps/js/dojo/1.4.3/dojo/dojo.js. This will give a dojo implementation for <g:formRemote>, <g:remoteField>, <g:remoteFunction>, <g:remoteLink> and <g:submitToRemote>. If you wish to use more of the dojo toolkit in your project, you can include it into your application by using the <dojo> tags.

Getting Started

To use dojo with the built in grails tags add the line to your Config.groovy file:
grails.views.javascript.library="dojo"

Next add the basic dojo header:

<dojo:header theme="soria" showSpinner="true"/>

Then add the theme definition to your body tag:

<body class="soria">

Include some dojo modules that you would like to use with the <dojo:header> tag or the <dojo:require> tag:

<dojo:header theme="soria" modules="['dijit.layout.TabContainer','dijit.layout.ContentPane', 'dijit.Editor']"/>

OR

<dojo:header theme="soria"/> <dojo:require modules="['dijit.layout.TabContainer','dijit.layout.ContentPane', 'dijit.Editor']"/>

Remote Pagination and Sorting

The dojo plugin also comes with <dojo:sortableColumn> and <dojo:paginate> tags. These tags support all the properties that the built-in grails tags supports and mixes in all the properties of the <g:remoteLink> tag.
<dojo:sortableColumn action="getList" property="color" title="Color" update="myUpdateRegion"/>

<dojo:paginate total="${total}" update="myUpdateRegion" next="Next Page" prev="Prev Page" action="listFragment"/>

Data Grid Tag

<html>
<head>
  <title>Simple Grid Example</title>
  <dojo:header theme="tundra"/>
  <dojo:gridResources/>
  <style type="text/css">
    .dojoxGridCell {font-size: 12px;}
    h2 {margin-top: 0;}
  </style>
</head>
<body class="tundra">
<% header = {
  return """
    <button style="float:left">Selected: ${dojo.bind(variable: 'myGrid.selected')}</button>
    <h2>My Widgets ( ${dojo.bind(variable: 'myGrid.rowCount')} )</h2>
  """
} %>
<dojo:grid name="myGrid" controller="widget" action="listJson" max="20" sort="name"
           style="height:200px; width:600px" header="${header}" selectable="true">
  <dojo:col width="50%" label="Name" field="name">{row.name} ({row.id})</dojo:col>
  <dojo:col width="15%" label="Color" field="color"/>
  <dojo:col width="15%" label="Shape" field="shape"/>
</dojo:grid>
</body>
</html>

The data grid only reads JSON data. So in WidgetController:

class WidgetController {

def listJson = { def widgets,widgetsTotal widgetsTotal = Widget.list().size(); widgets = Widget.list(params) render(contentType: "text/json") { identifier = "id" numRows = widgetsTotal items = array{ widgets.each {w -> item("id":w.id,"name":w.name,"color":w.color,"shape":w.shape) } } } } }

}

PopOver Tag

<dojo:popOverResources/>
<dojo:popOver label="Click to Activate PopOver" type="button">
    <div style="padding:2em">
        This is a popover that was activated by a click from a button.
    </div>
</dojo:popOver>

/* *** OR *** */

<dojo:popOver label="Load the action" type="button" controller="widget" action="popOverForm" containLinks="true"/>

More Information

Plugin version history

1.7.1.4 (February 7, 2012)

  • Switched from shrinksafe to google closure compiler for optimized dojo builds.
  • Fixed bugs in the <dojo:editor>
  • Addressed issue GPDOJO-12. This allows async=true for AMD modules.

1.7.1.4 (January 30, 2012)

  • Fixed a bug in the <dojo:editor>

1.7.1.3 (January 15th, 2012)

  • Bug fix for <dojo:tree> rendering issue with static data.
  • Added support for defining custom modules in <dojo:header>

1.7.1.2 (January 12th, 2012)

  • Bug fix of the static data in <dojo:tree>
  • Added <dojo:help> and <dojo:tooltip>

1.7.1.1 (January 10th, 2012)

  • Bug fix for the <dojo:editor>
  • Bug fix for <dojo:menu>
  • Added ability to specify static content in the <dojo:tree>
  • Added <dojo:panel>

1.7.0 (January 9th, 2012)

  • Upgraded to Dojo 1.7.1
  • Added <dojo:datePicker>, <dojo:timerPicker>, <dojo:dateTimePicker>, <dojo:numberPicker>
  • Added <dojo:editor>
  • Support new dojo optimization builder.

1.6.1.4 (February 1, 2012)

  • Fixed a bug in the optimized dojo build process.

1.6.1.4 (January 30, 2012)

  • Back-ported all changes in the 1.7.x version of the plugin to the 1.6 version.
  • This includes <dojo:menu>, <dojo:editor>, <dojo:help>, and <dojo:tooltip>.

1.6.1.3 (December 5, 2011)

  • Supports Grails 2.0.0.RC3
  • Added <dojo:tree> (<dojo:treeNode>, <dojo:treeLeaf>)
  • Changed <dojo:dataSourceView> to use name property instead of id.
  • Removed old unused code like dojoui.js
  • (GPDOJO-9) Changed from djConfig to dojoConfig.
  • Addded the showSpinner attribute to <dojo:header>
  • Addresses github issues #23, #10

1.6.1.2 (October 30, 2011)

  • Add support for Grails 2.0.0.RC1
  • Fixed 10 minor bugs.
  • Changed id to name for most tags that support action and controller. This follows grails conventions.
  • Added new attributes to the <dojo:dialog>
  • Added <dojo:onload> for <dojo:frames>

1.6.1.1 (September 6, 2011)

  • Add support for Grails 2.0

1.6.1.0 (August 27, 2011)

  • Upgraded to Dojo 1.6.1
  • Works in Firefox 3+ (including 4) IE 6-9

1.4.3.9 (March 9, 2011)

  • Fixed bug in <dojo:frame>
  • Fixed bug in <dojo:dataSourceView>

1.4.3.8 (February 22, 2011)

  • Added <dojo:frame> (<dojo:frameLink>)
  • Added <dojo:dialog> (<dojo:closeDialogButton>, <dojo:openDialog>)
  • Added <dojo:menu> (<dojo:menuSeparator>, <dojo:menuItem>)
  • Added <dojo:tabContainer> (<dojo:contentPane>)
  • Minor bug fixes in <dojo:popOver> and <dojo:popOverContent>

1.4.3.7 (February 11, 2011)

  • Added controller/action/params properties to the <dojo:popOver> tag. Allows remote content to be loaded.
  • Added containLinks to <dojo:popOver>. This keeps form submissions and links in the popOver.

1.4.3.6 (January 31, 2011)

  • Added <dojo:grid>, <dojo:col> and <dojo:bind> tags for interacting with Dojo Grids easily.
  • Added <dojo:dataSourceView>, <dojo:nodeTemplate>, and <dojo:nodeDefaultTemplate> for dataSource Templates
  • Added <dojo:css> for easily adding css files from the dojox namespace.

1.4.3.5 (December 13, 2010)

  • Changed the location of the dojo build definition from the dojo.profile.js to the Config.groovy file.

1.4.3.4 (December 7, 2010)

  • The full dojo toolkit is now included in the plugin.
  • Added new tags to bring dojo into the application: <dojo:header>, <dojo:require>
  • Added dojo packaging system to make an optimized dojo release during war creation.
  • Removed "install-dojo" script.
  • Added the optional "install-custom-dojo" to create an optimized dojo release outside of war creation.

1.4.3.2 (October 9, 2010)

  • Minor Bug fixes

1.4.3.1 (October 5, 2010)

  • Added support for simple strings in url param.
  • Added dojo taglib with ajax remote paginate and sortableColumn

1.4.3 (October 1, 2010)

For bugs and requests: http://jira.codehaus.org/browse/GRAILSPLUGINS/component/14542
Last updated by cfxram 1 month ago

1. How do I add dojo to my application?

  1. Install the plugin:
    grails install-plugin dojo
  2. Add this line to your Config.groovy file:
    grails.views.javascript.library="dojo"

2. How do I start adding dojo components to my application?

  1. Add this to the <head> section your GSP template or sitemesh layout:
    <dojo:header theme="tundra"/>
  2. Add this to your body tag:
    <body class="tundra">

3. How do I add tabs to my application?

  1. Add this code to your GSP for a tabView:
<dojo:tabResources/>
<dojo:tabContainer style="width:650px; height:200px">
  <dojo:contentPane title="My First Tab">
    This is the first tab.
  </dojo:contentPane>
  <dojo:contentPane title="My second tab.">
    This is the second tab.
  </dojo:contentPane>
</dojo:tabContainer>

4. How do I add a rich text editor?

  1. Simply add this to your GSP:
<dojo:editorResources/>
<dojo:editor type="intermediate" style="width:650px; height:300px;">
  <p>This is the initial content.</p>
</dojo:editor>

5. The dojo library is large. I don't need all of it. What can I do?

  • Dojo has a dynamic loader that will only include the files that you need. Yes, the entire library in the plugin is about 4MB (compressed), but only a small amount of code actually gets downloaded to the browser.

6. Can I speed things up when I release to production?

  • Absolutely. You will want to create a custom build for dojo. The dojo plugin has scripts to make this process easier for you. You can do this during war creation or you can run a grails script that will statically add your custom dojo build to your application. You can find more information about the Dojo Build Process on their website.

7. How do I define a custom dojo build?

  1. Add the dojo.profile setting to your Config.groovy file
  2. Here is an example of what should go in your Config.groovy file:
dojo.optimize.during.build = true; 
dojo.use.customBuild.js = true; 
dojo.css = """
  dependencies: [
    "../dojo/resources/dojo.css",
    "../dijit/themes/dijit.css",
    "../dijit/themes/tundra/tundra.css",
    "../dojoui/resources/css/dojo-ui.css",
    "../dojox/grid/resources/Grid.css",
    "../dojox/grid/resources/tundraGrid.css"
  ]
"""
dojo.profile = """
  var profile = {
    releaseDir:"release",
    layerOptimize: "shrinksafe.keepLines",
    cssOptimize: "comments.keepLines",

packages: [ {name: "css", location: "css"}, {name: "dojo", location: "dojo"}, {name: "dijit", location: "dijit"}, {name: "dojox", location: "dojox"}, {name: "dojoui", location: "dojoui"} ],

layers: { "dojo/plugin-custom-dojo": {include: [ "dojo/main", "dijit/layout/TabContainer", "dijit/layout/ContentPane", "dojo/io/iframe", "dijit/main", "dijit/_base", "dijit/_Widget", "dijit/Tooltip", "dijit/Dialog", "dijit/TooltipDialog", "dojoui/layout/ContentPane", "dojoui/layout/TabContainer", "dojoui/Bind", "dojoui/widget/DropDownButton", "dojoui/widget/DataSourceView", "dojoui/widget/Tree" ]} } }; """

8. I've defined my custom dojo build in my Config.groovy file, how do I add it to my war creation?

  1. Make sure these Config.groovy file settings are set like this:
dojo.optimize.during.build = true; 
dojo.use.customBuild.js = true;
  1. Build your war file:
    grails war

9. I'd rather add my custom dojo to my source code control. Can I do that?

  1. Make sure these Config.groovy file settings are set like this:
dojo.optimize.during.build = false; 
dojo.use.customBuild.js = true;
  1. Run the the custom dojo creation script:
    grails install-custom-dojo
  2. This will add your custom dojo build in webapps/js/dojo/1.7,0.1-custom/. You may add this directory to your source code if you wish.
Last updated by cfxram 1 year ago
Pictures of the dojo theme tester

Soria Theme:

Tundra Theme: