SimpleBlog is another good example. https://github.com/pascalrobert/SimpleBlog
> Hi Roger: > > Take a look at the ERRestRouteExample application from Wonder. It helped me > understand how all that Rest stuff works in Wonder. It has some nice inline > comments. I would take a look at Application.java, CarController.java and > CompanyController.java. Both the CarController and CompanyController have a > showAction that uses a parameter. > > Michael > > On 11/28/2012 9:46 AM, Roger Perryman wrote: >> >> On Nov 28, 2012, at 11:07 AM, Pascal Robert wrote: >> >>> >>> Le 2012-11-28 à 10:40, Roger Perryman <[email protected] >>> <mailto:[email protected]>> 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. >> >> If I understand you, you are saying to add these to my custom EO class: >> publicstaticfinalString LIST_PRACTICES_KEY= "listPractices"; >> public static final ERXKey<com.xeotech.resttest.datamodel.Practice> >> LIST_PRACTICES = new >> ERXKey<com.xeotech.resttest.datamodel.Practice>(LIST_PRACTICES_KEY); >> >> I still don't see how to retrieve the parameters to pass to this method. >> Also, based on a comment below, I assumed this method would live in the >> controller, not the EO. >> >>>> 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". >> >> So in the example above, practices is the name of a method inside my >> controller, not a relationship or attribute defined in the model? I >> can't find it now, but I seem to recall reading somewhere that if the >> framework cannot find a method, it check other places. Would the method >> without the final argument be more appropriate? And since I don't need >> to specify the Practice, how do I specify no parameters? >> >> routeRequestHandler.addRoute(new ERXRoute(Physician.ENTITY_NAME, >> "/Physician/{physician:Physician}/{listPractices:null}", >> ERXRoute.Method.Get, PhysicianController.class)); >> >>>> 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 protected]) >> Help/Unsubscribe/Update your Subscription: >> https://lists.apple.com/mailman/options/webobjects-dev/mhast%40desertsky.com >> >> This email sent to [email protected] >> > > -- > Tel: (602) 279-4600 ext: 635 > Desert Sky Software: www.desertsky.com > Specializing in the Development and Hosting of > e-Business Applications. > _______________________________________________ > Do not post admin requests to the list. They will be ignored. > Webobjects-dev mailing list ([email protected]) > Help/Unsubscribe/Update your Subscription: > https://lists.apple.com/mailman/options/webobjects-dev/probert%40macti.ca > > 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: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to [email protected]
