• 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: ERRest example of non-model method with parameters
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ERRest example of non-model method with parameters


  • Subject: Re: ERRest example of non-model method with parameters
  • From: Pascal Robert <email@hidden>
  • Date: Wed, 28 Nov 2012 11:07:32 -0500

Le 2012-11-28 à 10:40, Roger Perryman <email@hidden> a écrit :

> Hi All!
>
> I am still getting my feet wet with ERRest. Does anyone have an example of a REST call to a custom method on an EO that is not a model property and that takes parameters? All of the examples that I have found use model properties and just "automagically" work. The framework extracts the parameters and updates modeled properties. The only example of a non-model property was derivedCurrentTime but it doesn't use any parameters.

If the custom method is part of the EO class, you just need to add a ERXKey and add it to the keys for the response or request.

> For example, given an address (or latitude / longitude coordinates) and a distance, find all Practices within the specified distance from the address. I'm unclear on how to extract the parameters and use them in a custom method.
>
> Another example: I need to fetch all Practices that a Physician is associated with. I can get the list of Practices and I can get the list of Physicians. What is not clear is how to retrieve the Practices for the Physician. There is a relationship defined between Physicians and Practices. I'm sure it will end up requiring me to tweak my route setup.
>
> This is from the ERRestRouteExample.
>
> routeRequestHandler.addRoute(new ERXRoute(Person.ENTITY_NAME, "/Person/{person:Person}", ERXRoute.Method.Get, PersonController.class, "show"));
>
> Would I change it to
>
> routeRequestHandler.addRoute(new ERXRoute(Physician.ENTITY_NAME, "/Physician/{physician:Physician}/{practices:Practice}", ERXRoute.Method.Get, PhysicianController.class, "show"));
>
> It doesn't seem to work. Also, is "show" the proper choice? This is being sent to a client as data for a list and not displayed directly.

"show" is ok, as long as you have a "show" or "showAction" in PhysicianController. But for naming purposes, if you want to get a list of practices for a physician, I would call the method "listPractices".

> Is it OK to use addDefaultRoutes and also define additional routes? Or do I need to manually add all the routes if I need to customize any?

Yes it is ok.
 _______________________________________________
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: ERRest example of non-model method with parameters
      • From: Roger Perryman <email@hidden>
References: 
 >ERRest example of non-model method with parameters (From: Roger Perryman <email@hidden>)

  • Prev by Date: ERRest example of non-model method with parameters
  • Next by Date: Re: ERRest example of non-model method with parameters
  • Previous by thread: ERRest example of non-model method with parameters
  • Next by thread: Re: ERRest example of non-model method with parameters
  • Index(es):
    • Date
    • Thread