UI Plugin

Refactor DataSource to a standalone tag, and/or provide other ways to define YUI data source

Details

  • Type: New Feature New Feature
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: 1.0
  • Fix Version/s: 1.2
  • Component/s: None
  • Labels:
    None

Description

For autoComplete (and possibly datatable), I'd like a better control of the data source. ideally, it should support any or all of the following:

  • allow me to pass in a data source as a JavaScript reference
  • a builder/map to define the dataSource
  • a tag to define a datasource

why I want to do so? is the current implementation flexible enough to handle any requirement?

  • In autoComplete, I want to configure the dataURL by a String instead of controller+action.
  • In autoComplete, I want to use a TYPE_JSON response type instead of an Array response
  • by principle, it's better to support customization of any JavaScript component
  • reuse of data source (?possibly need a use case?)
  • using any data source features, e.g. type conversion
  1. GRAILSPLUGINS-610_DisplayTagLib.patch
    20/Nov/08 6:18 AM
    3 kB
    Mingfai Ma
  2. GRAILSPLUGINS-610.patch
    08/Nov/08 7:47 PM
    3 kB
    Mingfai Ma
  3. JSCategory.groovy
    20/Nov/08 6:21 AM
    3 kB
    Mingfai Ma

Activity

Hide
Mingfai Ma added a comment -

attached is a Utils / Category that could convert a Map to a piece of JavaScript. Refer to the method comment for the spec.

As demonstration, it converts the following Map:

def dataSource = [var: 'oDS', 'class': 'YAHOO.util.XHRDataSource',
            args: ['assets/php/ysearch_flat.php'],
            call: [['responseType': '$YAHOO.util.XHRDataSource.TYPE_TEXT ', 'responseSchema': [recordDelim: '\n', fieldDelim: '\t']],
                    ['flushCache'],
                    ['maxCacheEntries': 5]]]

to the following JavaScript String:

var oDS = new YAHOO.util.XHRDataSource("assets/php/ysearch_flat.php");
 oDS.responseType = YAHOO.util.XHRDataSource.TYPE_TEXT;
 oDS.responseSchema = {"recordDelim":"\n","fieldDelim":"\t"};
 oDS.flushCache();
 oDS.maxCacheEntries = 5;

(modified base on the data source at : http://developer.yahoo.com/yui/examples/autocomplete/ac_basic_xhr_clean.html )

Show
Mingfai Ma added a comment - attached is a Utils / Category that could convert a Map to a piece of JavaScript. Refer to the method comment for the spec. As demonstration, it converts the following Map:
def dataSource = [var: 'oDS', 'class': 'YAHOO.util.XHRDataSource',
            args: ['assets/php/ysearch_flat.php'],
            call: [['responseType': '$YAHOO.util.XHRDataSource.TYPE_TEXT ', 'responseSchema': [recordDelim: '\n', fieldDelim: '\t']],
                    ['flushCache'],
                    ['maxCacheEntries': 5]]]
to the following JavaScript String:
var oDS = new YAHOO.util.XHRDataSource("assets/php/ysearch_flat.php");
 oDS.responseType = YAHOO.util.XHRDataSource.TYPE_TEXT;
 oDS.responseSchema = {"recordDelim":"\n","fieldDelim":"\t"};
 oDS.flushCache();
 oDS.maxCacheEntries = 5;
(modified base on the data source at : http://developer.yahoo.com/yui/examples/autocomplete/ac_basic_xhr_clean.html )
Hide
Mingfai Ma added a comment -

patched autoComplete tag to take a dataSource parameter.

Show
Mingfai Ma added a comment - patched autoComplete tag to take a dataSource parameter.
Hide
Mingfai Ma added a comment -

added JS checking to avoid duplicated var declaration

Notice that this util is not necessarily to be a Category. it could be just a static util. if it is moved to the GrailsUITagLibService, it's better to be made as a static method. Please feel free to make change.

Show
Mingfai Ma added a comment - added JS checking to avoid duplicated var declaration Notice that this util is not necessarily to be a Category. it could be just a static util. if it is moved to the GrailsUITagLibService, it's better to be made as a static method. Please feel free to make change.

People

Vote (2)
Watch (0)

Dates

  • Created:
    Updated: