• 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
ERXRouteUrlUtils.actionUrlForRecord vs ERXRouteLink
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ERXRouteUrlUtils.actionUrlForRecord vs ERXRouteLink


  • Subject: ERXRouteUrlUtils.actionUrlForRecord vs ERXRouteLink
  • From: Pascal Robert <email@hidden>
  • Date: Sat, 19 Nov 2011 12:33:06 -0500

I just found a difference between the URL generated by ERXRouteUrlUtils.actionUrlForRecord vs ERXRouteLink. In SimpleBlog, I told ERRest that the primary key for a BlogEntry is the title instead of the primary key in the table. To do that, I created a BlogEntryRestDelegate class and:

  public Object primaryKeyForObject(Object obj, ERXRestContext context) {
    return ((BlogEntry)obj).title();
  }

  public Object objectOfEntityWithID(EOClassDescription entity, Object id, ERXRestContext context) {
    NSArray<BlogEntry> entries = ERXQ.filtered(BlogEntry.fetchAllBlogEntries(ERXEC.newEditingContext()), ERXQ.is("title", id));
    return entries.size() == 0 ? null : entries.objectAtIndex(0);
  }

That's working fine for ERXRouteLink, the generated link is using the title instead of the primary key, so I get /WOWODC.html instead of /1.html. Life is good… until I use ERXRouteUrlUtils.actionUrlForRecord, in that case, I was still getting 1.html.

Where is the difference? ERXRouteLink use this to get the primary key:

  Object entityID = IERXRestDelegate.Factory.delegateForEntityNamed(record.entityName()).primaryKeyForObject(record, new ERXRestContext(record.editingContext()));

ERXRouteUrlUtils.actionUrlForRecord use:

  record.primaryKeyInTransaction()

which at the end of the chain, calls ERXEOControlUtilities.primaryKeyObjectForObject. I changed locally the code so that actionUrlForRecord use the same logic as ERXRouteLink and it works fine, so anyone have a problem if I commit that change to Wonder?

 _______________________________________________
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: ERXRouteUrlUtils.actionUrlForRecord vs ERXRouteLink
      • From: Mike Schrag <email@hidden>
  • Prev by Date: null pointer maven create project
  • Next by Date: Re: ERXRouteUrlUtils.actionUrlForRecord vs ERXRouteLink
  • Previous by thread: null pointer maven create project
  • Next by thread: Re: ERXRouteUrlUtils.actionUrlForRecord vs ERXRouteLink
  • Index(es):
    • Date
    • Thread