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

ERRest example of non-model method with parameters


  • Subject: ERRest example of non-model method with parameters
  • From: Roger Perryman <email@hidden>
  • Date: Wed, 28 Nov 2012 10:40:23 -0500

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.

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.

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?

Thanks,

Roger

 _______________________________________________
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: Pascal Robert <email@hidden>
  • Prev by Date: Re: Partials and prototype boolean
  • Next by Date: Re: ERRest example of non-model method with parameters
  • Previous by thread: Re: Partials and prototype boolean
  • Next by thread: Re: ERRest example of non-model method with parameters
  • Index(es):
    • Date
    • Thread