You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Rashel Shehata <ra...@gmail.com> on 2007/05/17 13:39:45 UTC
repeater state and children
Hi,
Im having a problem setting the state of a certain child of a repeater .
I have a simple repeater defined as:
<fd:repeater id="selection" >
<fd:widgets>
<fd:field id="response" required="true" state="disabled">
<fd:label>Response Label</fd:label>
<fd:datatype base="string"/>
</fd:field>
..other children
</fd:widgets>
</fd:repeater>
Initially the response child is disabled but at some point i want to
activate all instances of the response child in the repeater
I have tried:
widget.lookupWidget("../selection").getChild("response").state=
Packages.org.apache.cocoon.forms.formmodel.WidgetState.ACTIVE;
but i get an error:
TypeError: Cannot set property "state" of null
i get the same error using widget.lookupWidget
("../selection").lookupWidget("response").
However on trying the method, the response widget is activated for row 0(as
expected):
widget.lookupWidget("../selection").getWidget(0,"response").state=
Packages.org.apache.cocoon.forms.formmodel.WidgetState.ACTIVE;
how do i activate all instances of the response widget in the repeater.
Thanks a miilion
Re: repeater state and children
Posted by Jason Johnston <co...@lojjic.net>.
Rashel Shehata wrote:
> Hi,
>
> Im having a problem setting the state of a certain child of a repeater .
>
> I have a simple repeater defined as:
> ...
>
>
> Initially the response child is disabled but at some point i want to
> activate all instances of the response child in the repeater
>
> I have tried:
> widget.lookupWidget("../selection").getChild("response").state=
> Packages.org.apache.cocoon.forms.formmodel.WidgetState.ACTIVE;
>
> but i get an error:
> TypeError: Cannot set property "state" of null
>
> i get the same error using
> widget.lookupWidget("../selection").lookupWidget("response").
>
> However on trying the method, the response widget is activated for row
> 0(as expected):
> widget.lookupWidget("../selection").getWidget(0,"response").state=
> Packages.org.apache.cocoon.forms.formmodel.WidgetState.ACTIVE;
>
> how do i activate all instances of the response widget in the repeater.
You can just loop over all the rows in the repeater:
var repeater = widget.lookupWidget("../selection");
for(var i=0; i<repeater.getSize(); i++) {
repeater.getWidget(i, "response").state =
Packages.org.apache.cocoon.forms.formmodel.WidgetState.ACTIVE;
}
Of course the field wouldn't be enabled by default in any new rows
added, so you'd need to write extra code to do so, probably an event
handler on your add-row button.
--Jason
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org