Re: Newbie Question:WOCheckBox
Re: Newbie Question:WOCheckBox
- Subject: Re: Newbie Question:WOCheckBox
- From: Denis Stanton <email@hidden>
- Date: Thu, 6 Nov 2003 09:20:14 +1300
On Wednesday, November 5, 2003, at 10:42 PM, Kranthi Sagar Borra wrote:
> Hi,
>
> I hava a WOCheckbox which I am populating with WORepetition.So my page
> now has as many checkboxes as there are objects in the list that we
> are using to iterate.So my problem now is to delete those rows for
> which the checkbox is clicked.So how do I track which checkbox is
> selected.Thanks in advance.
I have an array named items containing objects of class Item. They are
joined many-to one to an object named parent. ( i.e, one Parent can
have multiple Items). The Item class includes an attribute deleteItem
of type Integer. When I display item in a repetition I connect the
deleteItem to a check box, and I have methods that cause a checked
checkbox to put Integer(1) into deleteItem. Otherwise it will be
Integer(0). Then the action method includes the following:
int i;
for (i = parent.items().count() -1; i >= 0; i--){
if (
((Item)parent.items().objectAtIndex(i)).deleteItem().equals(new
Integer(1)) ){
session.defaultEditingContext().deleteObject(
(Item)parent.items().objectAtIndex(i) );
parent.removeFromItems( (Item)items().objectAtIndex(i)
);
}
}
Note that you have to start at the end of the array and work backwards.
if you use for (i = 0; i < parent.items().count(); i++){ and then
start deleting you'll mess up the count() value that control the loop
Denis Stanton
email@hidden
Home: (09) 533 0391
mobile: 021 1433622
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.