I somehow got it working... not sure if changing the serializer from
xhtml to html fixed it though.
<map:match pattern="searchform.jx">
<map:generate src="page/templates/searchform.jx" type="jx" />
<map:transform
src="resource/internal/xslt/forms-samples-styling.xsl">
<map:parameter name="dojo-resources"
value="{servlet:ajax:/resource/external/dojo}"/>
<map:parameter name="forms-resources"
value="{servlet:forms:/resource/external/forms}"/>
</map:transform>
<map:serialize type="html" />
</map:match>
From: Robby Pelssers [mailto:[email protected]]
Sent: Tuesday, September 15, 2009 11:26 PM
To: [email protected]
Subject: RE: cocoon.forms is undefined when using submit-on-change=true
for Field Widget
Diving a bit deeper into this issue I took a look at the scripts
included in the rendered html.
<head>
<script type="text/javascript">
var djConfig = {};
djConfig.locale = "en";
var cocoon;
if (!cocoon) cocoon = {};
cocoon.formsResourcesUri =
"/cocoon-forms-impl/resource/external/forms";
</script>
<script type="text/javascript"
src="/cocoon-ajax-impl/resource/external/dojo/dojo.js" />
<script type="text/javascript">dojo.require("dojo.widget.*");</script>
<script type="text/javascript"
src="/cocoon-forms-impl/resource/external/forms/js/forms-lib.js" />
<script type="text/javascript">
dojo.registerModulePath("cocoon.forms",
"/cocoon-forms-impl/resource/external/forms/js");
dojo.require("cocoon.forms.common");
dojo.require("cocoon.forms.manifest");
dojo.addOnLoad(cocoon.forms.callOnLoadHandlers);
</script>
</head>
So my next stop was taking a look at "forms-lib.js" where I noticed
following remark:
* This file has dependencies on cocoon.forms.common
* /_cocoon/resources/forms/js/common.js
*
However, I do not completely understand at this point how that script
will be loaded. I DO know that the url to get it is
http://localhost:8888/cocoon-forms-impl/resource/external/forms/js/commo
n.js
In this script I find back where cocoon.forms gets defined...
// Can be loaded either through "cocoon.forms" or "cocoon.forms.common"
// or individually out of Dojo.
if (dojo) {
dojo.provide("cocoon.forms");
dojo.provide("cocoon.forms.common");
} else {
cocoon = cocoon || {};
cocoon.forms = cocoon.forms || {};
}
So is my problem caused by the fact that this script is not loaded
properly?
Does it perhaps work like this??
* First you register the URL-path to the javascript resources
folder -> dojo.registerModulePath("cocoon.forms",
"/cocoon-forms-impl/resource/external/forms/js");
* Next you say what javascript files you need:
dojo.require("cocoon.forms.common");
dojo.require("cocoon.forms.manifest");
which makes an http request to
${modulePath}/${js-libraryname}.js ->
/cocoon-forms-impl/resource/external/forms/js/common.js
Well, if it does it still does not explain why cocoon.forms is
undefined.
Cheers,
Robby
From: Robby Pelssers [mailto:[email protected]]
Sent: Tuesday, September 15, 2009 11:00 PM
To: [email protected]
Subject: cocoon.forms is undefined when using submit-on-change=true for
Field Widget
Hi all,
I'm back again with a problem ;-) When adding the attribute
submit-on-change to a field widget (in a repeater) I see that the final
html gets added the following onchange attribute :
onchange="cocoon.forms.submitForm(this)".
Somehow cocoon.forms is undefined. Can anybody give me some insight as
to what could be wrong.... This would be mostly appreciated.
Thx in advance,
Robby Pelssers
Below relevant snippets:
Formdefinition:
<?xml version="1.0" encoding="UTF-8"?>
<fd:form xmlns:fd="http://apache.org/cocoon/forms/1.0#definition">
<fd:widgets>
<fd:repeater id="properties">
<fd:widgets>
<fd:field id="propertyName" state="output">
<fd:datatype base="string"/>
</fd:field>
<fd:field id="datatype" state="output">
<fd:datatype base="string"/>
</fd:field>
<fd:field id="operator">
<fd:datatype base="string"/>
</fd:field>
</fd:widgets>
</fd:repeater>
</fd:widgets>
</fd:form>
Template:
<ft:form action="#{$cocoon/continuation/id}.continue" method="POST"
>
<ft:repeater id="properties">
<table>
<tbody>
<ft:repeater-rows>
<tr>
<td>
<ft:widget id="propertyName"/>
</td>
<td>
<ft:widget id="datatype"/>
</td>
<td>
<ft:widget id="operator">
<fi:styling list-type="dropdown"
submit-on-change="true"/>
</ft:widget>
</td>
</tr>
</ft:repeater-rows>
</tbody>
</table>
</ft:repeater>
<br/>
<input type="submit" value="Search"/>
</ft:form>
Generated html output:
<td>
<span id="properties.0.operator">
<select name="properties.0.operator"
id="properties.0.operator:input" title="" class="forms field active"
onchange="cocoon.forms.submitForm(this)">
<option value="" />
<option value="EQUALS">=</option>
<option value="IS_NULL">is null</option>
<option value="IS_EMPTY">is empty</option>
<option value="CONTAINS">contains</option>
</select>
</span>
</td>