You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Leonard Broman <fi...@gmail.com> on 2008/10/19 00:02:06 UTC

RESTful Crud clean url:s, advanced howto anybody?

Hey!

I've been looking around quite some time for a solution how to build a
neat REST driven web application. What I basically want to do is
something like this:

GET /item/user/category/name

Should map to ItemController which has the properties user (username,
or id per default), category and name. Lets say that username,
category and name are coupled, so that there might be items with the
same and/or category that differs for different users. So, why not
just do /item/id? Well, it looks better.
So, I found the question on Don Browns blog
http://www.jroller.com/mrdon/entry/struts_2_rest_todos mentioning
something about mapping the @Namespace with wildcards and thus getting
the url to map cleanly to the dto properties. He also mentions it not
being well documented... To put it simple, I've tried doing this and I
can't get it to work (I really don't understand the principles so I'm
kinda lost). Actually no matter what I put in the Namespace
annotation, struts won't find my controller class anymore. Can anybody
provide a simple example for this?

/Leo

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: RESTful Crud clean url:s, advanced howto anybody?

Posted by Leonard Broman <fi...@gmail.com>.
I've been looking a little bit at the pattern matcher. Allthough I am
not sure that the namespace is the best location to configure this it
easily gets ambiguous with the patterns and it is hard to make the
same convention as for normal struts actions. I noticed the new (?)
Action annotation in the codebehind plugin and I think this would be a
proper place. Any how the */[name]/[value]/* isn't bad either since it
eliminates configuration. Personally I prefer it compact...

I'll try to look into this further when I get the time...

2008/10/25 Ryan Wong <la...@gmail.com>:
>
> hello,
>
>
> will u try the new feature NamedVariablePatternMatcher
> http://www.nabble.com/Some-Idea-On-REST-mapping-td19263471.html#a19263471
>
>
> Leonard Broman wrote:
>>
>> Hey!
>>
>> I've been looking around quite some time for a solution how to build a
>> neat REST driven web application. What I basically want to do is
>> something like this:
>>
>> GET /item/user/category/name
>>
>> Should map to ItemController which has the properties user (username,
>> or id per default), category and name. Lets say that username,
>> category and name are coupled, so that there might be items with the
>> same and/or category that differs for different users. So, why not
>> just do /item/id? Well, it looks better.
>> So, I found the question on Don Browns blog
>> http://www.jroller.com/mrdon/entry/struts_2_rest_todos mentioning
>> something about mapping the @Namespace with wildcards and thus getting
>> the url to map cleanly to the dto properties. He also mentions it not
>> being well documented... To put it simple, I've tried doing this and I
>> can't get it to work (I really don't understand the principles so I'm
>> kinda lost). Actually no matter what I put in the Namespace
>> annotation, struts won't find my controller class anymore. Can anybody
>> provide a simple example for this?
>>
>> /Leo
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>
>
> -----
> Blog: http://www.ryanwong.name
> Can Use: English, Chinese
> --
> View this message in context: http://www.nabble.com/RESTful-Crud-clean-url%3As%2C-advanced-howto-anybody--tp20051223p20161106.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: RESTful Crud clean url:s, advanced howto anybody?

Posted by Ryan Wong <la...@gmail.com>.
hello,


will u try the new feature NamedVariablePatternMatcher
http://www.nabble.com/Some-Idea-On-REST-mapping-td19263471.html#a19263471


Leonard Broman wrote:
> 
> Hey!
> 
> I've been looking around quite some time for a solution how to build a
> neat REST driven web application. What I basically want to do is
> something like this:
> 
> GET /item/user/category/name
> 
> Should map to ItemController which has the properties user (username,
> or id per default), category and name. Lets say that username,
> category and name are coupled, so that there might be items with the
> same and/or category that differs for different users. So, why not
> just do /item/id? Well, it looks better.
> So, I found the question on Don Browns blog
> http://www.jroller.com/mrdon/entry/struts_2_rest_todos mentioning
> something about mapping the @Namespace with wildcards and thus getting
> the url to map cleanly to the dto properties. He also mentions it not
> being well documented... To put it simple, I've tried doing this and I
> can't get it to work (I really don't understand the principles so I'm
> kinda lost). Actually no matter what I put in the Namespace
> annotation, struts won't find my controller class anymore. Can anybody
> provide a simple example for this?
> 
> /Leo
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 


-----
Blog: http://www.ryanwong.name
Can Use: English, Chinese
-- 
View this message in context: http://www.nabble.com/RESTful-Crud-clean-url%3As%2C-advanced-howto-anybody--tp20051223p20161106.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: RESTful Crud clean url:s, advanced howto anybody?

Posted by Martin Gainty <mg...@hotmail.com>.
Good Morning Leonard-

i see Wildcards in namespaces came from don's todo list from jroller:

where patrick mentioned 
@Namespace("/foo/{fooId}"),

this will call the setFooId() setter in your action (or more
accurately, set it on the valuestack)


as this is not yet implemented will you want to take a look?..
i think this would be a good feature to work on and i will help you any way I can

Please feel free to put this feature request into JIRA
https://issues.apache.org/struts/secure/Dashboard.jspa

Thanks,
Martin 
______________________________________________ 
Disclaimer and confidentiality note 
Everything in this e-mail and any attachments relates to the official business of Sender. This transmission is of a confidential nature and Sender does not endorse distribution to any party other than intended recipient. Sender does not necessarily endorse content contained within this transmission. 


> Date: Sun, 19 Oct 2008 00:02:06 +0200
> From: firepiper@gmail.com
> To: user@struts.apache.org
> Subject: RESTful Crud clean url:s, advanced howto anybody?
> 
> Hey!
> 
> I've been looking around quite some time for a solution how to build a
> neat REST driven web application. What I basically want to do is
> something like this:
> 
> GET /item/user/category/name
> 
> Should map to ItemController which has the properties user (username,
> or id per default), category and name. Lets say that username,
> category and name are coupled, so that there might be items with the
> same and/or category that differs for different users. So, why not
> just do /item/id? Well, it looks better.
> So, I found the question on Don Browns blog
> http://www.jroller.com/mrdon/entry/struts_2_rest_todos mentioning
> something about mapping the @Namespace with wildcards and thus getting
> the url to map cleanly to the dto properties. He also mentions it not
> being well documented... To put it simple, I've tried doing this and I
> can't get it to work (I really don't understand the principles so I'm
> kinda lost). Actually no matter what I put in the Namespace
> annotation, struts won't find my controller class anymore. Can anybody
> provide a simple example for this?
> 
> /Leo
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 

_________________________________________________________________
Stay organized with simple drag and drop from Windows Live Hotmail.
http://windowslive.com/Explore/hotmail?ocid=TXT_TAGLM_WL_hotmail_102008