• 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
Fwd: Re DisplayGroups. Inserting and deleting objs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fwd: Re DisplayGroups. Inserting and deleting objs


  • Subject: Fwd: Re DisplayGroups. Inserting and deleting objs
  • From: Jevon Hills <email@hidden>
  • Date: Wed, 22 Jan 2003 11:56:15 -0700

> From: Jevon Hills <email@hidden>
> Date: Wed Jan 22, 2003  11:11:24 AM Canada/Mountain
> To: Art Isbell <email@hidden>
> Cc: Jevon Hills <email@hidden>
> Subject: Re: Re DisplayGroups.  Inserting and deleting objs
>
> Thanx for your advice, but I'm still having some issues.  I believe
> these are around Editingcontext.
>
> When I first open the page I can remove any of the associated consoles
> no problem, but If i add a new console.  I am unable to remove it with
> out first killing and restarting my session.
>
> I get the unable to find guid for object.  so it appears That i don't
> manage to insert new objects into the editing context.
>
>
> Here is the code I used to associate a console with a card
>
> ------------
>   for (int icount = 0; icount < associateConsoles.count(); icount++)
>             {
>                     System.out.println("Add console " + (icount+1));
>
>                     Console con = (Console)
> associateConsoles.objectAtIndex(icount);
>                     //System.out.println("Add Console " + con);
>
>                     if (!selectedSCConsoles.containsObject(con))
>                     {
>                         System.out.println("Need to add this one");
> 			selectedSCConsoles.addObject((Console) con);
>
>                         // build smplt and add to groups
>                         ConsoleSmartCardLinkTable csclt = new
> ConsoleSmartCardLinkTable();
>
> csclt.setSmartcardid(selectedCard.smartcardid());
>                         csclt.setConsoleid(con.consoleid());
>                         csclt.setSmartcard(selectedCard);
>
>                         //System.out.println("Insert into EC");
>                         con.addToConsolesmartcardlinktable(csclt);
>                         ec.insertObject(csclt);//class attribute of
> session().defaulteditingcontext()
>                     }
> 		}
> 		try
> 		{
>                     saveChanges();
>                 }
>
> ------------------
> This seems to work fine, but I'm not 100% certain of this.
>
> Here is my remove Association code
>
> ---------------------------
>             while(selectedSCSelectedConsoles.count() > 0)
>             {
>                     System.out.println("*******NEXT CONSOLE");
>
>                     currentConsole = (Console)
> selectedSCSelectedConsoles.objectAtIndex(0);
>
>                     System.out.println("*****Remove " +
> currentConsole.consoleid() + " " + currentConsole.consolename() + "
> from list*****");
>
>                     NSArray list =
> currentConsole.consolesmartcardlinktable();
>                     for(int i = 0; i < list.count(); i++)
>                     {
>                         ConsoleSmartCardLinkTable smplt =
> (ConsoleSmartCardLinkTable) list.objectAtIndex(i);
>                         System.out.println("smplt: " +
> smplt.consoleid() + "\t" + smplt.smartcardid());
>                         if(smplt.smartcardid()==null)
>                         {
>                         }
>                         else
> if(smplt.smartcardid().intValue()==selectedCard.smartcardid().intValue(
> ))
>                         {
>
> System.out.println("----DELETEING-----");
>
> selectedCard.removeFromConsolesmartcardlinktables(smplt);
>                                 EOEditingContext delEC =
> smplt.editingContext();
>                                 delEC.deleteObject(smplt);
>
> selectedSCConsoles.removeObject(currentConsole);
>                         }
>
> selectedSCSelectedConsoles.removeObject(currentConsole);
>                     }
>             }
>
>             try
>             {
>                 saveChanges();
>             }
> ------------------------------------------------
> With this I get the null guid. But only on the items I have added in
> the current session.
>
> And finally the saveChanges() Method
> ----------------------------------------------
> 	private void saveChanges()
> 		throws Exception
> 	{
>             try
>             {
>                 System.out.println("SAVING");
>                 ec.saveChanges();
>             }
>             catch (Exception exception)
>             {
>                 // An error occurred during the save. You could present
>                 //an error page which explains the reason for the save
>                 //failure. The default is to raise an exception which
>                 //presents a diagnostic page.
>                 System.out.println("Unable to save while WHILESAVING");
>
>                 NSLog.err.appendln("Cannot save changes ");
>                 throw exception;
>             }
>
> 	}
>
> ---------------------------------------------
> Thank you again for your help.
>
> On Wednesday, January 15, 2003, at 12:46 PM, Art Isbell wrote:
>
>> On Wednesday, January 15, 2003, at 07:03  AM, Jevon Hills wrote:
>>
>>> will be using card keys for security.  A card key can only access a
>>> console if it is associated with it.  This is a many to Many relation
>>> ship modeled in the database by a table of CardKeys, a table of
>>> Consoles and a linktable between the 2.  the link table contains
>>> cardid
>>> and consoleid.
>>>
>>> so when I add a Console to a Card I just add a row to the link table
>>> and, obviously when I remove an association I delete a row.
>>
>> 	Methinks you are working too hard.  If you let EOModeler build your
>> many-to-many relationship, it creates flattened to-many relationships
>> between each entity.  If you use those relationships, you won't have
>> to reference the link entity at all.  In fact, it should be marked as
>> Abstract since there's no need to ever create any link entity objects
>> in your app.
>>
>> Art
>> http://homepage.mac.com/aisbell/
>> _______________________________________________
>> 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.
>>
>>
> Jevon K. Hills
> Intern - Zymeta Media Promotion Systems
>
Jevon K. Hills
Intern - Zymeta Media Promotion Systems
_______________________________________________
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.

  • Prev by Date: Re: Webobjects newsgroup? GMANE!
  • Next by Date: Re: Re DisplayGroups. Inserting and deleting objs
  • Previous by thread: Re: Re DisplayGroups. Inserting and deleting objs
  • Next by thread: Re: Re DisplayGroups. Inserting and deleting objs
  • Index(es):
    • Date
    • Thread