Jeroen Reijn Escribio :-)
> Hi,
>
> there was some effort of updating to dojo 1.1, but the work in the
> branch as far as I know is not finished.
>
> Jeroen
Hi Jeroen.
thanks for the feedback.
I'm trying to help in the testing, I know Jeremy work sometime ago
on this branch.
So, in anycase I'm attaching another patch, this patch is to make work
again the suggestion list of type javascript:
<fd:suggestion-list type="javascript">
--
Cheers.
Carlos Chávez.
>
> On Mon, Jul 5, 2010 at 6:56 AM, "Carlos Chávez" <[email protected]> wrote:
>> Hi guys.
>>
>> I was testing the branch
>> http://svn.apache.org/repos/asf/cocoon/branches/BRANCH_2_1_X-dojo1_1. I
>> enter in the sample:
>>
>> http://localhost:8888/samples/blocks/forms/do-calculatedfields.flow
>>
>> I tried to add a row to the repeater and it shows the error:
>>
>> dojoId is not defined.
>>
>> I attached to the email the fix for this error.
>>
>> --
>> Cheers.
>> Carlos Chávez.
>>
>
### Eclipse Workspace Patch 1.0
#P BRANCH_2_1_X-dojo1_1
Index:
src/blocks/forms/resources/org/apache/cocoon/forms/resources/forms-advanced-field-styling.xsl
===================================================================
---
src/blocks/forms/resources/org/apache/cocoon/forms/resources/forms-advanced-field-styling.xsl
(revision 960158)
+++
src/blocks/forms/resources/org/apache/cocoon/forms/resources/forms-advanced-field-styling.xsl
(working copy)
@@ -47,13 +47,14 @@
<xsl:param name="dojo-resources"><xsl:value-of
select="$context-path"/>/_cocoon/resources/dojotoolkit</xsl:param> <!-- Url
prefix for dojo resources -->
<xsl:param name="forms-resources"><xsl:value-of
select="$context-path"/>/_cocoon/resources/forms</xsl:param> <!-- Url
prefix for forms block resources -->
<xsl:param name="forms-system"><xsl:value-of
select="$context-path"/>/_cocoon/system/forms</xsl:param> <!-- Url
prefix for forms block system pipelines -->
-
+ <xsl:param
name="forms-suggest">_cocoon/system/forms/suggestionlist</xsl:param>
<!-- Special case for the suggest widget -->
+
<!-- set the default dojo css theme, other choices are currently 'nihilo'
and 'soria' -->
<xsl:param name="dojo-theme-default">tundra</xsl:param>
-
+
<!-- A convenient way for samples to have a url that switches the theme. If
your app does not want this, don't send this param from your sitemap -->
<xsl:param name="dojo-theme-param"></xsl:param>
-
+
<!-- the determine dojo css theme to use -->
<xsl:variable name="dojo-theme">
<xsl:choose>
@@ -61,15 +62,15 @@
<xsl:otherwise><xsl:value-of
select="$dojo-theme-param"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
-
+
<!-- option to turn on console debugging for dojo on the browser and loading
of uncompressed resources, from a parameter in the sitemap -->
<xsl:param name="dojo-debug">false</xsl:param>
<xsl:variable name="dojo-debug-js"><xsl:if
test="$dojo-debug='true'">.uncompressed.js</xsl:if></xsl:variable><!-- load the
uncompressed version for debug mode -->
<xsl:variable name="dojo-debug-css"><xsl:if
test="$dojo-debug='true'">.commented.css</xsl:if></xsl:variable>
-
+
<!-- Configure the dojo locale from a parameter in the sitemap (required?).
-->
- <xsl:param name="dojo-locale"></xsl:param>
-
+ <xsl:param name="dojo-locale"></xsl:param>
+
<!-- Create a variable with the normalized locale, dojo needs locale parts
to be separated with a dash -->
<xsl:variable name="dojoLocale">
<xsl:choose>
@@ -81,7 +82,7 @@
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
-
+
<!-- create a variable for the dojo configuration -->
<xsl:variable name="djConfig">
isDebug: <xsl:value-of select="$dojo-debug"/>,
@@ -94,11 +95,11 @@
locale: '<xsl:value-of select="$dojoLocale"/>'<xsl:if test="$dojo-use-cdn
= 'true' and $dojo-cdn != ''">,
dojoBlankHtmlUrl: '<xsl:value-of
select="$dojo-resources"/>/dojo/resources/blank.html',
dojoIframeHistoryUrl: '<xsl:value-of
select="$dojo-resources"/>/dojo/resources/iframe_history.html', <!-- not
currently used by cforms itself -->
- baseUrl: './',
+ baseUrl: './',
xdWaitSeconds: 10</xsl:if>
</xsl:variable>
- <xsl:template match="head" mode="forms-field">
+ <xsl:template match="head" mode="forms-field">
<xsl:choose>
<xsl:when test="$dojo-use-cdn = 'true' and $dojo-cdn != ''">
<link rel="stylesheet" type="text/css"
href="{$dojo-cdn}/dijit/themes/dijit.css"/><!-- Google CDN does not keep
*.commented.css -->
@@ -146,11 +147,11 @@
| Adds support for live data validation on the client, based on
fi:datatype
| (Browser validation may be turned off with
fi:styling/@browserValidation="false")
+-->
-
+
<!-- TODO: Document new options -->
<!-- TODO: fi:styling/@regExp should not be a user tag, it should come
from the validator (eventually?) -->
-
- <xsl:template match="fi:field[not(fi:styling/@type='inplace-area') and
(@state='active' or @state='disabled')] |
+
+ <xsl:template match="fi:field[not(fi:styling/@type='inplace-area') and
(@state='active' or @state='disabled')] |
fi:aggregatefield[not(fi:styling/@type='inplace-area')
and (@state='active' or @state='disabled')]">
<!-- isValidating --><xsl:variable name="v" select="@required = 'true' or
fi:validation-message or fi:styling/@regExp != '' or
fi:styling/@browserValidation != 'false'"/>
<!-- isFormatted --><xsl:variable name="f"
select="fi:datatype/fi:convertor"/>
@@ -399,7 +400,7 @@
+-->
<xsl:template match="fi:field[(fi:styling/@type='suggest' or
fi:styling/@dataUrl != '') and @state='active']" priority="1">
<xsl:variable name="value" select="fi:value"/>
- <xsl:variable name="isStore" select="not(fi:selection-list) or
fi:styling/@dataUrl"/>
+ <xsl:variable name="isStore" select="not(fi:selection-list) or
fi:styling/@dataUrl"/>
<!-- <xsl:variable name="queryExpr">
<xsl:choose>
<xsl:when test="fi:styling/@match = 'contains'">*${0}*</xsl:when>
@@ -438,7 +439,7 @@
| A dojo.data ReadStore for retrieving suggestion lists dynamically
| Works with either a fd:suggestion-list/@type="javascript" in the Model
| - in which case the fd:suggestion-list must contain an implementation
- | and there must be pipeline at "_cocoon/forms/suggest" (relative)
+ | and there must be pipeline at
"_cocoon/system/forms/suggestionlist" (relative)
| that uses the SuggestionListGenerator to return the list (see
samples)
| Or fi:styling/@dataUrl in the Template
| - in which case there must be a pipeline at that url to return the
list
@@ -458,18 +459,17 @@
<xsl:if test="fi:styling/@pageSize"><xsl:attribute
name="pageSize"><xsl:value-of
select="fi:styling/@pageSize"/></xsl:attribute></xsl:if>
<xsl:choose>
<xsl:when test="$isWidget">
- <!-- TODO: maybe a candidate for a system pipeline? -->
- <!-- Reads from a widget, via a pipeline: you must have a pipeline
that serves this url
- - the widget adds: continuation-id, widget (name) and filter
(search) request parameters
+ <!-- Reads from a widget, via a pipeline: you must have a pipeline
that serves this url relative
+ - the widget adds: continuation-id, widget (name) and filter
(search) request parameters
- there must be a suggestion-list providing this data, in your
Model -->
- <xsl:attribute name="url"><xsl:value-of
select="$forms-system"/>/suggestionlist</xsl:attribute>
+ <xsl:attribute name="url"><xsl:value-of
select="$forms-suggest"/></xsl:attribute>
<xsl:attribute name="client"><xsl:value-of
select="@id"/>:input</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<!-- Reads from a pipeline: you must have a pipeline that serves
this url (the widget adds a filter request parameter) -->
- <xsl:attribute name="url"><xsl:value-of
select="$forms-system"/>/suggestionlist/<xsl:value-of
select="fi:styling/@dataUrl"/></xsl:attribute>
+ <xsl:attribute name="url"><xsl:value-of
select="$context-path"/>/<xsl:value-of select="$forms-suggest"/>/<xsl:value-of
select="fi:styling/@dataUrl"/></xsl:attribute>
</xsl:otherwise>
- </xsl:choose>
+ </xsl:choose>
</div>
</xsl:template>
Index: src/blocks/forms/samples/forms/lists.xml
===================================================================
--- src/blocks/forms/samples/forms/lists.xml (revision 960158)
+++ src/blocks/forms/samples/forms/lists.xml (working copy)
@@ -170,7 +170,6 @@
</fd:selection-list>
</fd:field>
- <!-- TODO: this version of the FilteringSelect WIdget is not working
properly yet. -->
<fd:field id="personId">
<fd:label>Person</fd:label>
<fd:help>A suggestion-list made using a Widget, by adding a
fd:suggestion-list/@type="javascript" to the model.</fd:help>
Index: src/blocks/forms/resources/org/apache/cocoon/forms/system/sitemap.xmap
===================================================================
--- src/blocks/forms/resources/org/apache/cocoon/forms/system/sitemap.xmap
(revision 960158)
+++ src/blocks/forms/resources/org/apache/cocoon/forms/system/sitemap.xmap
(working copy)
@@ -20,7 +20,7 @@
CForms system pipelines sitemap
- @version $Id$
+ @version $Id$
-->
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
@@ -42,32 +42,23 @@
<map:flow language="javascript">
<map:script src="System.Collections.js"/>
</map:flow>
-
+
<map:pipelines>
<map:pipeline>
-
+
<!-- JSON support -->
<map:match pattern="send-json">
<map:read src="module:flow-attr:json"
mime-type="text/json-comment-filtered" />
</map:match>
-
- <!--+
- | Show a suggestion list provided by a Widget
- +-->
- <map:match pattern="suggestionlist">
- <map:generate type="suggestion-list"/>
- <!-- <map:transform type="i18n"/>TODO: SHould'nt need i18n
(once implemented in ) -->
- <map:transform
src="resource://org/apache/cocoon/forms/resources/selection-list2json.xsl"/>
- <map:serialize type="json"/>
- </map:match>
-
+
+ <!-- the parameter {1} represent the name of the register function
that serve
+ the list of elements to populate the widget -->
<map:match pattern="suggestionlist/*">
<map:call function="System.Collections.doSuggestionList">
<map:parameter name="id" value="{1}"/>
</map:call>
</map:match>
-
-
+
</map:pipeline>
</map:pipelines>
Index: src/blocks/forms/samples/forms/lists_template.xml
===================================================================
--- src/blocks/forms/samples/forms/lists_template.xml (revision 960158)
+++ src/blocks/forms/samples/forms/lists_template.xml (working copy)
@@ -17,10 +17,10 @@
-->
<!-- The only difference between this file and the form1_template_flow.xml
is the value of the action attribute on the ft:form-template element -->
-<page xmlns:ft="http://apache.org/cocoon/forms/1.0#template"
+<page xmlns:ft="http://apache.org/cocoon/forms/1.0#template"
xmlns:fi="http://apache.org/cocoon/forms/1.0#instance"
xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
-
+
<!-- Import the macros that define CForms template elements -->
<jx:import
uri="resource://org/apache/cocoon/forms/generation/jx-macros.xml"/>
<jx:import uri="resources/samples-jx-macros.xml"/><!-- common macros for
samples -->
@@ -89,9 +89,9 @@
<ft:widget id="vegetables">
<fi:styling type="suggest"/>
</ft:widget>
- <!--<ft:widget id="personId"> TODO: currently broken,
org.apache.cocoon.forms.generation.SuggestionListGenerator cannot find the
continuation
+ <ft:widget id="personId">
<fi:styling type="suggest"/>
- </ft:widget>-->
+ </ft:widget>
<ft:widget id="workplace">
<fi:styling type="suggest" dataUrl="countries"
pageSize="10"/>
</ft:widget>
@@ -107,10 +107,10 @@
</fi:group>
</fi:items>
</fi:group>
-
+
<p><ft:widget id="ok"/></p>
</div>
- <p>Supported Locales:
+ <p>Supported Locales:
<sample-locale-chooser/><!-- a macro from samples-jx-macros.xml -->
</p>
<p>
Index:
src/blocks/forms/resources/org/apache/cocoon/forms/resources/selection-list2json.xsl
===================================================================
---
src/blocks/forms/resources/org/apache/cocoon/forms/resources/selection-list2json.xsl
(revision 960158)
+++
src/blocks/forms/resources/org/apache/cocoon/forms/resources/selection-list2json.xsl
(working copy)
@@ -29,15 +29,15 @@
<xsl:template match="fi:selection-list">
<dummy-root>
- <xsl:text>[ </xsl:text>
+ <xsl:text>/*({identifier:"value", label:"label", items:[</xsl:text>
<xsl:apply-templates/>
- <xsl:text> ]</xsl:text>
+ <xsl:text>]})*/</xsl:text>
</dummy-root>
</xsl:template>
<xsl:template match="fi:item">
- <xsl:text>["</xsl:text>
- <!-- displayed text -->
+ <xsl:text>{label:"</xsl:text>
+ <!-- label -->
<xsl:choose>
<xsl:when test="fi:label">
<xsl:value-of select="fi:label"/>
@@ -46,10 +46,10 @@
<xsl:value-of select="@value"/>
</xsl:otherwise>
</xsl:choose>
- <xsl:text>", "</xsl:text>
+ <xsl:text>", value:"</xsl:text>
<!-- value -->
<xsl:value-of select="@value"/>
- <xsl:text>"]</xsl:text>
+ <xsl:text>"}</xsl:text>
<xsl:if test="position() != last()">
<xsl:text>, </xsl:text>
</xsl:if>
Index: src/blocks/forms/samples/sitemap.xmap
===================================================================
--- src/blocks/forms/samples/sitemap.xmap (revision 960158)
+++ src/blocks/forms/samples/sitemap.xmap (working copy)
@@ -200,14 +200,14 @@
<!--
| Show a suggestion list
-->
- <map:match pattern="_cocoon/forms/suggest">
+ <map:match pattern="_cocoon/system/forms/suggestionlist">
<map:generate type="suggestion-list"/>
<map:transform type="i18n"/>
<map:transform
src="resource://org/apache/cocoon/forms/resources/selection-list2json.xsl"/>
<map:serialize type="json"/>
</map:match>
- <map:match pattern="_cocoon/forms/suggest/*">
+ <map:match pattern="_cocoon/system/forms/suggestionlist/*">
<map:call function="{1}Lookup"/>
</map:match>
<map:match pattern="*.json-combo-data">