You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Massimiliano Cantoni <ma...@assicom.com> on 2004/06/24 10:48:44 UTC

Woody binding problem

Hi all,

I am using cocoon for building a web application and in particular I am using woody (Cocoon forms) for handling forms.

I have the following problem:

I have modified the example "form_model_gui" to learn how to use the class and struct widgets.

<>I need these widgets because my final goal form is complex and I want 
to reuse the code.

I have substituted file form_model_gui_data.xml with the following lines:

<?xml version="1.0" encoding="iso-8859-1"?>
<page xmlns:util="http://apache.org/xsp/util/2.0"
xmlns:xsp="http://apache.org/xsp"
xmlns:infoutil="http://www.unifactor.com/infocomm/util/1.0"
xmlns:xsp-cookie="http://apache.org/xsp/cookie/2.0"
xmlns:xsp-session="http://apache.org/xsp/session/2.0"
xmlns:xspdoc="http://apache.org/cocoon/XSPDoc/v1"
xmlns:esql="http://apache.org/cocoon/SQL/v2"
xmlns:xsp-request="http://apache.org/xsp/request/2.0">
<title align="center">Anagrafiche trovate:</title>
<CONTENT>
<PRATINFO>
<IDPRAT>226171</IDPRAT>
<IDAZ>2</IDAZ>
</PRATINFO>
<response>
<header>
<result>1</result>
<description>Anagrafica Identificata!!!</description>
<messages />
</header>
<body>
<ANAGRAFICHE >
<ANAGRAFICA>
<UBICAZIONE>
<INDIRIZZO>
<DESCRIZIONE>PIAZZA DELLA REPUBBLICA,
1</DESCRIZIONE>
</INDIRIZZO>
</UBICAZIONE>
</ANAGRAFICA>

<ANAGRAFICA>
<UBICAZIONE>
<INDIRIZZO>
<DESCRIZIONE>PIAZZA DELLA REPUBBLICA,
2</DESCRIZIONE>
</INDIRIZZO>
</UBICAZIONE>
</ANAGRAFICA>

</ANAGRAFICHE>
</body>
</response>
</CONTENT>
</page>

I replaced the file form_model_gui_binding.xml with the following lines:

<?xml version="1.0" encoding="ISO-8859-1"?>

<wb:context xmlns:wb="http://apache.org/cocoon/woody/binding/1.0"
xmlns:wd="http://apache.org/cocoon/woody/definition/1.0"
path="/page/CONTENT"
lenient="true">

<wb:context path="PRATINFO">
<wb:value id="IDPRAT" path="IDPRAT"/>
<wb:value id="IDAZ" path="IDAZ"/>
</wb:context>

<wb:context id="body" path="response/body">

<wb:new id="ANAGRAFICHE-CLASS"/>

<wb:class id="ANAGRAFICHE-CLASS">
<wb:struct id="ANAGRAFICHE" path=".">
<wb:temp-repeater id="REPANAGRAFICHE"
parent-path="ANAGRAFICHE"
row-path="*"
row-path-insert="."
virtual-rows="true">
<wb:on-bind>
<wb:new id="ANAGRAFICA-CLASS"/>
</wb:on-bind>
</wb:temp-repeater>
</wb:struct>
</wb:class>

<wb:class id="ANAGRAFICA-CLASS">
<wb:struct id="ANAGRAFICA" path="ANAGRAFICA">
<wb:new id="UBICAZIONE-CLASS"/>
</wb:struct>
</wb:class>

<wb:class id="UBICAZIONE-CLASS">
<wb:struct id="UBICAZIONE" path="UBICAZIONE">
<wb:new id="INDIRIZZO-CLASS"/>
</wb:struct>
</wb:class>

<wb:class id="INDIRIZZO-CLASS">
<wb:struct id="INDIRIZZO" path="INDIRIZZO">
<wb:value id="DESCRIZIONE" path="DESCRIZIONE"/>
</wb:struct>
</wb:class>

</wb:context>

</wb:context>

and I have substituted the contents of file form_gui_template.xml with 
the following lines:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE DOCUMENT SYSTEM "COMMON-ENTITIES-DEF.dtd">
<wd:form
xmlns:wd="http://apache.org/cocoon/woody/definition/1.0">

<wd:widgets>

<wd:messages id="messages">
<wd:label>Errori</wd:label>
</wd:messages>

<wd:field id="IDPRAT">
<wd:label>Pratica:</wd:label>
<wd:datatype base="string"/>
</wd:field>

<wd:field id="IDAZ">
<wd:label>Azienda:</wd:label>
<wd:datatype base="string"/>
</wd:field>

<!-- Nuovo oggetto per contenere le anagrafiche -->

<wd:new id="ANAGRAFICHE-CLASS"/>


<!-- classe per l'oggetto -->

<wd:class id="ANAGRAFICHE-CLASS">
<wd:widgets>
<wd:struct id="ANAGRAFICHE">
<wd:widgets>
<wd:repeater id="REPANAGRAFICHE" initial-size="1">
<wd:label>Anagrafiche</wd:label>
<wd:widgets>
<wd:new id="ANAGRAFICA-CLASS"/>
</wd:widgets>
</wd:repeater>
</wd:widgets>
</wd:struct>
</wd:widgets>
</wd:class>

<wd:class id="ANAGRAFICA-CLASS">
<wd:widgets>
<wd:struct id="ANAGRAFICA">
<wd:widgets>
<wd:new id="UBICAZIONE-CLASS"/>
</wd:widgets>
</wd:struct>
</wd:widgets>
</wd:class>

<wd:class id="UBICAZIONE-CLASS">
<wd:widgets>
<wd:struct id="UBICAZIONE">
<wd:widgets>
<wd:new id="INDIRIZZO-CLASS"/>
</wd:widgets>
</wd:struct>
</wd:widgets>
</wd:class>

<wd:class id="INDIRIZZO-CLASS">
<wd:widgets>
<wd:struct id="INDIRIZZO">
<wd:widgets>
<wd:field id="DESCRIZIONE">
<wd:datatype base="string"/>
<wd:label>Descrizione:</wd:label>
</wd:field>
</wd:widgets>
</wd:struct>
</wd:widgets>
</wd:class>

</wd:widgets>

</wd:form>

I run the example and the binding seem to work correctly as I can see 
the form filled with the values from
data file.

I try to submit the form, ( I am expecting an error because the 
following pipeline is not correct but I expect
to find the xml data I modify stored in form_model_gui_data-result.xml) 
I get the following error with no xml data output.

uncaught JavaScript exception: at form_model_gui 
(file:/D:/Programmi/java/eclipse/workspace/cocoon/samples/woody/flow/form_model_gui.js, 
Line 32) at 
(resource://org/apache/cocoon/woody/flow/javascript/woody2.js, Line 
198): org.apache.commons.jxpath.JXPathException: Cannot create a 
relative context for a non-existent node: /ANAGRAFICA

org.apache.avalon.framework.CascadingRuntimeException: uncaught 
JavaScript exception: at form_model_gui 
(file:/D:/Programmi/java/eclipse/workspace/cocoon/samples/woody/flow/form_model_gui.js, 
Line 32) at 
(resource://org/apache/cocoon/woody/flow/javascript/woody2.js, Line 
198): org.apache.commons.jxpath.JXPathException: Cannot create a 
relative context for a non-existent node: /ANAGRAFICA


Am I using the right approach or class and struct elements have to be 
used in another way?

I cannot understand why binding works during loading but not for saving 
the form.

I used temp-repeater because I have no id for the repeater elements. 
Maybe there is another way to use the normal repeater or can someone 
address me to find some documentation on temp-repeater?

Maybe this iussue is solved in CForms so it is better for me to migrate 
to the new enviroment? (Migration is an already scheduled job but I need 
to be sure it works before migrating).

Thanks to all and sorry about my bad English

Massimiliano Cantoni







---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org