CForms: Updating all instances of a widget in a repeater

2006-04-06 Thread Stewart, Gary
Hi there,

I've got a repeater with two selection lists in; staffmemeber and staffrole. 
Upon a value being changed on the staffrole or another selection list outside 
of the repeater (department) the list of staff members change. I'm using an 
on-changed-value on the staffrole repeater and that works fine but I'd also 
like to change the list if the department is updated for all the rows in the 
repeater using javascript on the department's on-changed-value event. 

I tried something like:

var staff_list = event.source.parent.lookupWidget(stafflist).getChildren();
var staff_item = null;
var staff_member = null;
var staff_role = null;
while(staff_list.hasNext())
{
staff_item = staff_list.next();
  staff_member = staff_item.lookupWidget(staffmember);
  staff_role = staff_item.lookupWidget(staffrole);
//set a new staff member event
}

but I got stuck at the first hurdle. That is that it looks like stafflist 
doesn't actually have any children (hasNext() returns false). It certainly 
should have. If it does have children is it then possible to do the latter 
logic of getting each child and looking up the components I want to get the 
value of and change the values of? 

Is there a different or better way that I should do this?

Thanks,

Gary

*
The information contained in this message may be confidential or 
legally privileged and is intended for the addressee only. If you 
have received this message in error or there are any problems 
please notify the originator immediately. The unauthorised use, 
disclosure, copying or alteration of this message is 
strictly forbidden.
*


If you work for NHS Lothian and wish to have help to stop smoking, support is 
available by contacting [EMAIL PROTECTED] or 0131 537 9494  - internal 49494.  
For anyone else living/working in Lothian, please contact 0800 848484 for your 
nearest NHS stop smoking service.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: CForms: Updating all instances of a widget in a repeater

2006-04-06 Thread Jason Johnston
Stewart, Gary wrote:
 Hi there,
 
 I've got a repeater with two selection lists in; staffmemeber and
 staffrole. Upon a value being changed on the staffrole or another
 selection list outside of the repeater (department) the list of staff
 members change. I'm using an on-changed-value on the staffrole
 repeater and that works fine but I'd also like to change the list if
 the department is updated for all the rows in the repeater using
 javascript on the department's on-changed-value event.
 
 I tried something like:
 
 var staff_list = event.source.parent.lookupWidget(stafflist).getChildren();
 var staff_item = null;
 var staff_member = null;
 var staff_role = null;
 while(staff_list.hasNext())
 {
   staff_item = staff_list.next();
   staff_member = staff_item.lookupWidget(staffmember);
   staff_role = staff_item.lookupWidget(staffrole);
   //set a new staff member event
 }
 
 but I got stuck at the first hurdle. That is that it looks like
 stafflist doesn't actually have any children (hasNext() returns
 false). It certainly should have. If it does have children is it then
 possible to do the latter logic of getting each child and looking up
 the components I want to get the value of and change the values of?
 
 Is there a different or better way that I should do this?

I think to get the rows from a Repeater you have to use getRow() rather
than getChildren(). I think I've used something like this in the past:

var repeater = ...
for(var i=0; irepeater.getSize(); i++) {
  var row = repeater.getRow(i);
  ...
}

Hope that works

Actually the Javadoc for Repeater doesn't even look like it has a
getChildren() method, so I'm not sure why you weren't getting an error.
It seems odd that Repeater doesn't implement ContainerWidget; even its
Javadoc says it should.  Interesting.

--Jason



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: CForms: Updating all instances of a widget in a repeater

2006-04-06 Thread Stewart, Gary


 -Original Message-
 From: Jason Johnston [mailto:[EMAIL PROTECTED]
 Sent: 06 April 2006 14:00
 To: users@cocoon.apache.org
 Subject: Re: CForms: Updating all instances of a widget in a repeater

 I think to get the rows from a Repeater you have to use 
 getRow() rather
 than getChildren(). I think I've used something like this in the past:
 
 var repeater = ...
 for(var i=0; irepeater.getSize(); i++) {
   var row = repeater.getRow(i);
   ...
 }
 
 Hope that works
 
 Actually the Javadoc for Repeater doesn't even look like it has a
 getChildren() method, so I'm not sure why you weren't getting 
 an error.

You are quite right; it isn't part of the class. I'll double check the code is 
actually being called :D. Thanks for pointing me to the correct documentation. 
For some reason I was looking at the container class.

Thanks again,

Gary

*
The information contained in this message may be confidential or 
legally privileged and is intended for the addressee only. If you 
have received this message in error or there are any problems 
please notify the originator immediately. The unauthorised use, 
disclosure, copying or alteration of this message is 
strictly forbidden.
*


If you work for NHS Lothian and wish to have help to stop smoking, support is 
available by contacting [EMAIL PROTECTED] or 0131 537 9494  - internal 49494.  
For anyone else living/working in Lothian, please contact 0800 848484 for your 
nearest NHS stop smoking service.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]