• 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
Re: WORepetition, checked attribute question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: WORepetition, checked attribute question


  • Subject: Re: WORepetition, checked attribute question
  • From: David Holt <email@hidden>
  • Date: Tue, 05 Dec 2006 10:30:55 -0800

Hi Mark,

Oh man! All that code reduced to:

NSMutableArray favourites;

public ElementSearch(WOContext context) {
super(context);

favourites();

}


/** @TypeInfo Element */
public NSMutableArray favourites() {
if (favourites == null) {
favourites = (NSMutableArray)user.favouriteElements();
}
return favourites;
} 

    public boolean elementChecked()
    {
        return favourites.containsObject(anElement);
    }

public void setElementChecked(boolean newElementChecked) {


// Jerry Walker's code:
// is the element already in the favourites?
boolean oldValue = elementChecked();
// if selected, and not already in the favourites list, add it
if (newElementChecked && !oldValue) {
user.addObjectToBothSidesOfRelationshipWithKey(anElement, "favouriteElements");
}
// if not selected but already in the favourites list, remove it
else if ( !newArtifactChecked && oldValue) {
user.removeObjectFromBothSidesOfRelationshipWithKey(anElement, "favouriteElements");
}

}


public WOComponent submit()
{
Session session = (Session)session();
EOEditingContext ec = session.defaultEditingContext();
ec.saveChanges(); 
return null;
}


Where do I send the beer??

I didn't realize that I could cast the NSArray user.favouriteElements() to NSMutableArray. That was pretty much the key. NOW it's FAST!

Thanks so much,

David

-- 

It's like driving a car at night. You never see further than your headlights, but you can make the whole trip that way. 


E. L. Doctorow


from Sunbeams: http://www.thesunmagazine.org 



On 5 Dec 2006, at 9:41 AM, Mark Morris wrote:

you should be able to directly use user.favouriteElements() instead of going through selectionList.  In other words, elementChecked and setElementChecked can directly work on userFavouriteElements().

 _______________________________________________
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

  • Follow-Ups:
    • Re: WORepetition, checked attribute question
      • From: Pierre Bernard <email@hidden>
References: 
 >Re: WORepetition, checked attribute question (From: David Holt <email@hidden>)
 >Re: WORepetition, checked attribute question (From: Mark Morris <email@hidden>)

  • Prev by Date: Re: Performance on new xserves ? BENCHMARKED
  • Next by Date: <WO Job Posting> Need WO Developers for full-time/part-time position
  • Previous by thread: Re: WORepetition, checked attribute question
  • Next by thread: Re: WORepetition, checked attribute question
  • Index(es):
    • Date
    • Thread