cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Johnston <coc...@lojjic.net>
Subject Re: repeater state and children
Date Thu, 17 May 2007 13:37:43 GMT
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


Mime
View raw message