sounds right

On Nov 19, 2011, at 12:33 PM, Pascal Robert wrote:

> 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 protected])
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/webobjects-dev/mschrag%40pobox.com
> 
> This email sent to [email protected]

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to