strange enum error
strange enum error
- Subject: strange enum error
- From: Stephen Todd <email@hidden>
- Date: Tue, 22 Feb 2005 14:36:16 -0700
We have a method that removes all objects from a many-to-many
relationship then adds in new values. It uses the code that follows the
message. When we try and empty the array it only ends up removing half
the items. When investigating what happens, I discovered that the
enumeration returns values for the first half in the list containing
the even items, and then null values for the second half.
I get the following output from the System.outs below when
newAdminAreas is empty (code below the output:
//1
newAdminAreas:0
//2
user.ACLs: [an array showing all the items previously set. None are
null]
//3
if there are four items, I get two acls and then null twice. It appears
like these are the 2nd and 4th. With more items, it just removes the
even ones.
//4
This is half the original user.ACLs().count()
public void setAdminAreas(NSArray newAdminAreas)
{
System.out.println("newAdminAreas:"+newAdminAreas.count()); //1
//remove all rights
System.out.println("user.ACLs:"+user.ACLs()); //2
Enumeration aclEnum = user.ACLs().objectEnumerator();
while(aclEnum.hasMoreElements())
{
ACL acl = (ACL)aclEnum.nextElement();
System.out.println("remove:"+acl); //3
user.removeObjectFromBothSidesOfRelationshipWithKey(acl, "ACLs");
}
System.out.println("user.ACLs(): "+user.ACLs().count()); //4
....<snip>
-Stephen
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden