cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Johnston <coc...@lojjic.net>
Subject Re: form.getChild() function problem
Date Thu, 02 Aug 2007 01:01:04 GMT
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


Mime
View raw message