You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Stephan Coboos <cr...@gmx.net> on 2004/12/02 08:00:24 UTC
Re: [CForms] How to iterate other a model?
Sylvain Wallez wrote:
> Stephan Coboos wrote:
>
>> Hello,
>>
>> is it possible to iterate other a model object within a flowscript?
>> The model object was retrieved before by calling form.getModel().
>
>
>
> Yes, you can use lookupWidget() that accepts a path-like syntax (i.e.
> "a/b/c" or "../d")
>
>> Another question: Is there an API doc available for this object?
>
>
>
> http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/forms/formmodel/package-summary.html
>
>
> Sylvain
>
Hi Sylvain,
that's why I'am a little bit confused about the documentation because
model.lookupWidget("age") as well as other methods from type Widget
doesn't work in my flowscript. I got this exception:
Original Exception: TypeError: lookupWidget is not a function. (file:/E:/container/instances/testsys/webapps/evalsys/app/flows/fillOut.js; line 13)
at org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java:581)
at org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java:541)
In the listing below you can see the part in my flowscript:
var form = new Form("cocoon:/formDefinition/" + inquiryName);
form.showForm("formTemplate/" + inquiryName);
var model = form.getModel();
print("Widget: :" + model.lookupWidget("age"));
What's wrong here?
Thank you for your help!
Regards
Stephan
Re: [CForms] How to iterate other a model?
Posted by Jorg Heymans <jh...@domek.be>.
Stephan Coboos wrote:
> Sylvain Wallez wrote:
>
>> Stephan Coboos wrote:
>>
> var model = form.getModel();
> print("Widget: :" + model.lookupWidget("age"));
^^^^^^^^^^^^^^^^^^
lookupWidget is a method of the Form object, not of the model.
Jorg
Re: [CForms] How to iterate other a model?
Posted by Stephan Coboos <cr...@gmx.net>.
Hi,
after I had tried several times to iterate over a widget using
flowscript (model.lookupWidget()) I had realized that - in my opinion -
this is not easily possible. The problem: I don't know the id's of the
widgets! So there are two big questions I'm having:
1)
In Java I can use .getChilds() of a ContainerWidget which returns me an
iterator to iterate over all childs of an widget. I couldn't find such a
method in the flowscript API. How to solve this problem? Either I need a
length of all childs and then I can get one by one by pointing to its
index or I need an iterator.
2.)
I didn't find a way to resolve a Widget value of type MultiValueField.
Therefore its not possible to retrieve such values. None of "typeof" or
"instanceof" worked correctly to determine the object type. How can I
resolve whether it is a MultiValueField or not?
Thanks!
Regards
Stephan
Re: [CForms] How to iterate other a model?
Posted by Sylvain Wallez <sy...@apache.org>.
Stephan Coboos wrote:
> Hi Sylvain,
>
> I have resolved my problem: I have to include the v2 Form.js and to
> change form.getModel() to form.getWidget().
>
> Thanks.
Well, don't thank me, I was of little help in finding the solution ;-)
Sylvain
--
Sylvain Wallez Anyware Technologies
http://www.apache.org/~sylvain http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }
Re: [CForms] How to iterate other a model?
Posted by Stephan Coboos <cr...@gmx.net>.
Hi Sylvain,
I have resolved my problem: I have to include the v2 Form.js and to
change form.getModel() to form.getWidget().
Thanks.
Regards
Stephan