• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Many-To-Many Problem Revisited
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Many-To-Many Problem Revisited


  • Subject: Many-To-Many Problem Revisited
  • From: "Jonathan Fleming" <email@hidden>
  • Date: Wed, 08 Jan 2003 15:10:30 +0000

I have posted something on this twice but have received not one reply, so I'm going to condense it if it helps.

In the application, when I save a selection of categories in the WOBrowser the appear to save ok but when rebuild and run the application and go back to the page with the list of categories I find that every category in the list has been highlighted instead of the selection I made and this happens on every object in the application that has this many-to-many link.

What is going on? What am I doing wrong? Or is this a bug?

In the meantime I find some code that I though might cure the problem, but it doesn't seem to be working (see below).

In finding this code it has made me think that there is some vital code I am missing when saving to a flattened many-to-many relationship. Does anyone know if this is so and if so can you please post it with a brief explanation on how to implement it if necessary.

Kind regards
Jonathan

PS. this is that code:

public NSArray tbCatJoin_tbCategorys() {
       return (NSArray)storedValueForKey("tbCatJoin_tbCategorys");
   }

   public void setTbCatJoin_tbCategorys(NSMutableArray value) {
       int index;

       this.willChange();

for ( index=0; index<this.tbCatJoin_tbCategorys().count(); index++ ) {
TbCategory tbCategory = (TbCategory)this.tbCatJoin_tbCategorys().objectAtIndex(index);
this.removeObjectFromBothSidesOfRelationshipWithKey( tbCategory,"tbCatJoin_tbCategorys" );
}
for ( index=0; index<value.count(); index++ ) {
TbCategory tbCategory = (TbCategory)value.objectAtIndex(index);
this.addObjectToBothSidesOfRelationshipWithKey( tbCategory, "tbCatJoin_tbCategorys");
}
}


   public String inverseForRelationshipKey( String key ) {
       if ( key.equals("tbCatJoin_tbCategorys") ) {
           return "tbCatJoin_tbClients";
           }
           return super.inverseForRelationshipKey( key );
   }

   public void addToTbCatJoin_tbCategorys(TbCategory object) {
       NSMutableArray array = (NSMutableArray)tbCatJoin_tbCategorys();

       willChange();
       array.addObject(object);
   }

   public void removeFromTbCatJoin_tbCategorys(TbCategory object) {
       NSMutableArray array = (NSMutableArray)tbCatJoin_tbCategorys();

       willChange();
       array.removeObject(object);
   }






_________________________________________________________________
MSN 8: advanced junk mail protection and 2 months FREE*. http://join.msn.com/?page=features/junkmail
_______________________________________________
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.

  • Follow-Ups:
    • Re: Many-To-Many Problem Revisited
      • From: Art Isbell <email@hidden>
  • Prev by Date: WOBrowser Content Problem...
  • Next by Date: Problem with update to 5.1.4
  • Previous by thread: WOBrowser Content Problem...
  • Next by thread: Re: Many-To-Many Problem Revisited
  • Index(es):
    • Date
    • Thread