Folks, this type of nested resource is how a Rails REST url work and its
awesome.  So easy to configure and so easy to use with things like 

     link_to :chapter_path(@book) 

That will make the /book/book.getId()/chapter/chapter.getId() url.   There
is no doubt that providing nested resources would make the REST
implementation in Struts2 better.  

You are looking at the url from right to left.  The first resource has a
parameter of id, and then for each level up the tree you get object_id for
the parameter.   

So if I post a get for /book/1/section/2/chapter/12 I would get the
following parameters sent to the ChapterContoller: (id = 12, section_id = 2,
book_id = 1).  

In apps with a REST design I only really need to know the parent in the url
when I am creating a child.  So to use the book example,
(/chapters/new?parent_id=1).  Once my chapter is created it is forever
connected to the book with id 1.  After I create a chapter I can reference
it directly by its id (/chapter/22) and if I want the book I can do a
chapter.getBook() once I look up the chapter in the controller.  I don't
really have many situations where something doesn't have a unique id and has
to be looked up with a combo of parent_id and child
number?position?whatever?

I don't think its useful to argue about what a "true" RESTful URL looks
like.  


Mike Watson-2 wrote:
> 
> Hmmm, I haven't come across the Namspace annotation stuff. I'll
> investigate that and see how I get on. If anyone can point me at some
> useful examples of how I might achieve this it'd be greatly
> appreciated.
> 
> Thanks again for all the responses...
> 
> 2008/6/17 Don Brown <[EMAIL PROTECTED]>:
>> I believe it is technically possible to do this, but not at all
>> intuitive right now.  This is probably my number one improvement
>> request for the REST plugin.
>>
>> You should be able change the wildcard mapper to one that recognizes
>> named wildcards then use them in your namespace annotation like this:
>> @Namespace("/book/{bookId}")
>>
>> As I said, it really needs work as this is a huge deficiency in the
>> REST plugin right now, but the reason I haven't just made this easier
>> as I'm toying with the idea of borrowing the URI mapping behavior from
>> Jersey, which I find very intuitive, if a bit un-Struts/xwork-like.
>>
>> Don
>>
>> On Tue, Jun 17, 2008 at 9:10 AM, Mike Watson <[EMAIL PROTECTED]>
>> wrote:
>>> Well that'd be nice but I'm really struggling to get it to behave the
>>> way I want. Any thoughts on how I might do this?
>>>
>>> 2008/6/17 Dave Newton <[EMAIL PROTECTED]>:
>>>> --- On Mon, 6/16/08, Mike Watson <[EMAIL PROTECTED]> wrote:
>>>>> Can anybody suggest where I would start in an attempt to
>>>>> implement this hierarchical model?
>>>>
>>>> The existing REST plugin?
>>>>
>>>> Just an idea.
>>>>
>>>> Dave
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/REST-plugin-URL-syntax-tp17855192p17959769.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to