Hi Verdin,
 
In response to your question

"I would like to know what's the difference between Forms.showForm() and cocoon.sendPageAndWait()."

and your example using jx template generator...

"So I use a flowscript, in which I create a form object and send it to the pipeline with form.showForm :

function sendForm(){

var form = new Form("forms/definitions.xml");

form.showForm("display-form");

} "

....

I would take a guess that you're not importing the correct Form.js. You're probably importing version 1 of Form.js as follows in your .js file:

cocoon.load("resource://..../forms/flow/_javascript_/Form.js");

This (v1) version of Form.js in turn defines the following class at the top of the file:

defineClass("org.apache.cocoon.forms.flow._javascript_.ScriptableWidget");

However....

The forms (form1) sample which uses the jx:macros is in the v2 directory. If you notice, the v2/forms_flow_example.js in that directory imports at the top:

cocoon.load("resource://..../forms/flow/_javascript_/v2/Form.js");

Notably, this Form.js defines the class:

defineClass("org.apache.cocoon.forms.flow._javascript_.v2.ScriptableWidget");

at the top of the file.

What does it mean?

First to clarify the difference between form.showForm and cocoon.sendPageAndWait().

Essentially, form.showForm (in Form.js) does a cocoon.sendPageAndWait() for you, but it makes sure that your form object is passed into the pipeline as bizData. So, form.showForm("my-display-pipeline") is roughly equivalent to cocoon.sendPageAndWait("my-display-pipeline",["bizData":myForm]).

Note that the myForm is the form which is returned in:

var f = new Form("definition.xml");

and this "f" is actually an instance of ScriptableWidget, returned to you by Form.js, or an instance of v2.ScriptableWidget returned to you by v2/Form.js.

So, I think the problem is that the myForm you are instantiating is a ScriptableWidget not a v2.ScriptableWidget, and the way Form.js handles the formContext is different from v1 to v2. The v1 method is not compatible with the way jx:macros lookup the 'form', expecting to find a v2.ScriptableWidget.

Hope this helps

James

 


ALL-NEW Yahoo! Messenger - all new features - even more fun!

Reply via email to