struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ken McWilliams <ken.mcwilli...@gmail.com>
Subject Re: [Question] [struts2-rest-plugin] How shall I handle GET request /orders/{id}/items?
Date Wed, 07 Sep 2016 22:01:40 GMT
There isn't a recommended way to handle deeply set lists as per your
example... Or I missed it. I'm not a fan of that plugin.

It is really trivial to do this without any plugins:
https://struts.apache.org/docs/wildcard-mappings.html
Wildcards or using the named-pattern matcher (although in the linked
documentation the heading is "Parameters in namespaces").

It may be possible to use conventions, it might be nice to use annotations
to specify the root and the child actions in the same class for grouping:
http://stackoverflow.com/questions/6037820/is-it-possible-to-use-wildcard-method-invocation-in-struts2-with-conventions-plu

Since you may need to resolve the child entity before fetching the child,
it might be convenient to have them in the same class... save you from
chaining.

Create/Update/Delete using the struts2-rest-plugin are pretty straight
forward but at only one level of access.



On Wed, Sep 7, 2016 at 3:45 AM, Yong Kang Guo <guogin@outlook.com> wrote:

> Hi experts,
>
> I'm learning to use the struts2-rest-plugin. In the sample project
> 'rest-showcase', I see a good example where I can GET /orders and
> /orders/1. But how to implement navigation from one resource to another?
> E.g., Let's say an Order has many Items. Then how to implement the proper
> handler to request:
>
> GET /orders/{id}/items, and
>
> GET /orders/{id}/items/{item_id} ?
>
>
> And how to handle Create/Update/Delete requests to the navigation path,
> e.g.
>
> POST /orders/{id}/items
>
> to create a new item under the order?
>
>
> Thanks and Best Regards,
>
> Guo
>



-- 
Sent from my C64 using a 300 baud modem

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message