You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Alan Menant <al...@gmail.com> on 2007/08/01 15:58:25 UTC

form.getChild() function problem

Hello,

I'm trying to get all widgets from a form with the getChildren function :

var form = new Form(myForm.xml);
var myWidgets = form.getChildren();
form.showForm("myform-display-pipeline");

But I get an error message telling getChildren() is not function (
form.getChild('xxx') works fine). I saw the function in Cocoon 2.1.10 API
but I'm using Cocoon 2.2 (I got the same error with Cocoon 2.1.9).

May this useful function have been removed ?


Alan

Re: form.getChild() function problem

Posted by Alan Menant <al...@gmail.com>.
2007/8/2, Jason Johnston <co...@lojjic.net>:
>
> Alan Menant wrote:
> > Hello,
> >
> > I'm trying to get all widgets from a form with the getChildren function
> :
> >
> > var form = new Form(myForm.xml);
> > var myWidgets = form.getChildren();
> > form.showForm("myform-display-pipeline");
> >
> > But I get an error message telling getChildren() is not function
> > (form.getChild('xxx') works fine). I saw the function in Cocoon 2.1.10
> > API but I'm using Cocoon 2.2 (I got the same error with Cocoon 2.1.9).
> >
> > May this useful function have been removed ?
>
> I think your confusion is that when you do "new Form()" from your
> flowscript, you don't get an org.apache.cocoon.forms.formmodel.Form Java
> object that has the getChildren() method, but instead you get an
> instance of the javascript class Form (see [1]) which wraps an instance
> of the Java class.
>
> Thankfully the javascript Form object allows you to get access to the
> underlying java Form object by using the getWidget() method.  So
> changing your code to:
>
>     var myWidgets = form.getWidget().getChildren();
>
> ...should work.
>
> --Jason
>
> [1]
>
> http://svn.apache.org/repos/asf/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/resources/org/apache/cocoon/forms/flow/javascript/Form.js


Ok, thank you Jason for the explanation. It works perfectly.

Alan

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

Re: form.getChild() function problem

Posted by Jason Johnston <co...@lojjic.net>.
Alan Menant wrote:
> Hello,
> 
> I'm trying to get all widgets from a form with the getChildren function :
> 
> var form = new Form(myForm.xml);
> var myWidgets = form.getChildren();
> form.showForm("myform-display-pipeline");
> 
> But I get an error message telling getChildren() is not function 
> (form.getChild('xxx') works fine). I saw the function in Cocoon 2.1.10 
> API but I'm using Cocoon 2.2 (I got the same error with Cocoon 2.1.9).
> 
> May this useful function have been removed ?

I think your confusion is that when you do "new Form()" from your 
flowscript, you don't get an org.apache.cocoon.forms.formmodel.Form Java 
object that has the getChildren() method, but instead you get an 
instance of the javascript class Form (see [1]) which wraps an instance 
of the Java class.

Thankfully the javascript Form object allows you to get access to the 
underlying java Form object by using the getWidget() method.  So 
changing your code to:

    var myWidgets = form.getWidget().getChildren();

...should work.

--Jason

[1] 
http://svn.apache.org/repos/asf/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/resources/org/apache/cocoon/forms/flow/javascript/Form.js

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