You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Stephane Delort <St...@edag.de> on 2004/08/11 13:32:35 UTC
[cforms] struct and class access in flowscript
Hi,
I have this definition file :
<fd:widgets>
<fd:class id="widgetClass">
<fd:widgets>
<fd:union id="union" default="" case="type">
<fd:datatype base="string"/>
<fd:widgets>
<fd:struct id="simpleList">
<fd:widgets>
<fd:multivaluefield id="list">
<fd:label>just another List </fd:label>
<fd:datatype base="string"/>
<fd:selection-list type="flow-jxpath" list-path="list"
value-path="value" label-path="label"/>
</fd:multivaluefield>
</fd:widgets>
</fd:struct>
<fd:struct id="complexList">
<fd:widgets>
<fd:multivaluefield id="list">
<fd:label>just a complex List </fd:label>
<fd:datatype base="string"/>
<fd:selection-list type="flow-jxpath" list-path="list"
value-path="value" label-path="label"/>
</fd:multivaluefield>
<fd:repeater id="lists">
<fd:widgets>
<fd:new id="widgetClass"/>
</fd:widgets>
</fd:repeater>
</fd:widgets>
</fd:struct>
</fd:widgets>
</fd:union>
</fd:widgets>
</fd:class>
I would like to fill it with values from a bean, in a flowcsript so I did ;
var model = form.getModel();
var p = form.lookupWidget("widgetClass");
var f = p.lookupWidgetWidget("union").getChild("simpleList").lookupWidget
("list"); /* error here because p is null*/
f.setSelectionList( c, "listId", "label" );
but then I have a "cannot convert nul to a n object" error (p is null)
I took a look at the cocooon API but I really don't know how to deal with
class, union, ans struct in flowscript (or java).
any help greatly appreciated,
Stephane
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: [cforms] struct and class access in flowscript
Posted by Tim Larson <ti...@keow.org>.
On Wed, Aug 11, 2004 at 01:32:35PM +0200, Stephane Delort wrote:
<snip/>
> I would like to fill it with values from a bean, in a flowcsript so I did ;
>
> var model = form.getModel();
> var p = form.lookupWidget("widgetClass");
> var f = p.lookupWidgetWidget("union").getChild("simpleList").lookupWidget
> ("list"); /* error here because p is null*/
> f.setSelectionList( c, "listId", "label" );
>
> but then I have a "cannot convert nul to a n object" error (p is null)
> I took a look at the cocooon API but I really don't know how to deal with
> class, union, ans struct in flowscript (or java).
>
> any help greatly appreciated,
> Stephane
I don't have time to describe all of it right now, but this might
help get you started...
<fd:widgets>
<fd:class id="someClass">
<fd:widgets>
<fd:field id="myField">
<!-- fill in widget details here -->
</fd:field>
</fd:widgets>
</fd:class>
<fd:struct id="spacer">
<fd:new id="someClass"/>
</fd:struct>
<fd:widgets>
A "fd:class" is not a real widget...it is just a blueprint for
creating widgets. So you need to put an "fd:new" where you want
to build an instance of the widgets described by this blueprint.
Note in the sample above that I wrapped the "fd:new" with an
"fd:struct"...this is because the "fd:class" and the "fb:new"
must be in different "namespaces" since they use the same id.
You could instead wrap the "fd:new" in a repeater or a union...
anything that would put it in a different namespace.
To access "myField" from flowscript or java, you would use
lookupWidget to reference "spacer.myField"...note that neither
the "fd:class" nor the "fd:new" are referenced.
--Tim Larson
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org