Well after doing some research on designing rest api ***best practices*** I realized I was doing something wrong.
For getting all companies, we must use http://localhost/company For getting all locations of that company we can use http://localhost/company/111/locations For anything else to get from any particular location we can use http://localhost/company/locations/111 - to get location details ****(/company/ only in namespacing ) http://localhost/company/locations/111/contacts - to get location contacts etc............. Now question is how do we implement namespacing in struts2 rest api??? As by default all actions are @root right? can we have @namespace(value="/company/") annotation in Location Action???? But this does not work for me, it redirects to company action only and says no method available. Or we must not use such namespacing and its better to use http://localhost/location instead of http://localhost/company/location Please suggest. On Fri, Jan 23, 2015 at 4:20 PM, Amol Ghotankar <ghotankaru...@gmail.com> wrote: > hi, > > I was trying out struts2 rest plugin and found it really cool. > > But was just wondering how will this work with action cascading ? i.e > > So When using http://localhost/company it goes to companyAction and > executes respective mapped methods > > But how do we organize work when we > http://localhost/company/1/locations/2/contact/2/ ??? > > Will these be methods in same class? Class will grow too big & if not how > does it get mapped to contactAction and pass values their? > > How about more complex case where we have > http://localhost/company/1/locations/2/contact/2/order/2/transaction/1/payment > or something like this??? > > Domain objects are hibernate entities when company has locations has > contacts has orders has transaction has payments? > > or should the rest url be something different and simplified? like > http://localhost/order/2/transaction/1/payment but still has issues > mapping things and reusing actions? > > Am I missing something in rest plugin? > > -- > > > > *With Best Regards,* > > Amol Ghotankar > Technical Lead > M: +91 9960 980 419 <http://www.cursivetech.com> > -- *With Best Regards,* Amol Ghotankar Technical Lead M: +91 9960 980 419 <http://www.cursivetech.com>