Hi Simon
On Thu, Apr 14, 2011 at 11:02 PM, Simon Chen <[email protected]> wrote:
> Hi all,
>
> I have some trouble putting a somewhat nested set of paths working in
> jax-rs...
>
> The idea is that we have:
>
> @Path("/webstore/")
> class WebStore {
>
> @Path("/users/{name}/")
> User getUser(@PathParam("name") String name) {
> return this.userList.get(name);
> }
> }
>
> With this, I can get "/webstore/users/some_one" to retrieve a
> particular user called "some_one".
>
> But let's say I also have:
>
> class User {
> @Path("/comments/{id}")
> Comment getComment(@PathParam("id") String id) {
> return this.commentList.get(id);
> }
> }
>
> What I want is to be able to get
> "/webstore/users/some_one/comments/c_100/", where "some_one" is the
> user ID and "c_100" is the comment ID.
>
>
OK
> I don't think this is working however I change the way I annotate
> "User" class. Is it possible?
>
> That really has to work. What exactly is not working ?
'User' acts as a subresource, the question is, but 'Comment' also acts as a
subresource, because
getComment() has no @GET.
If Comment is the final bean that has to be returned then add @GET to
getComment(). Or, alternatively, have a Comment method which returns the
actual content annotated with @GET
Hope it helps
Sergey
> Thanks!
> -Simon
>
--
Sergey Beryozkin
Application Integration Division of Talend <http://www.talend.com>
http://sberyozkin.blogspot.com