You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Frans Thamura <fl...@meruvian.org> on 2008/01/18 17:26:10 UTC
REST vs Original
hi there
i just want to know, how to mixe the code between S2 and with REST under one
container.
any idea?
or anyone have an example that 'this is the old' and 'this is the REST'
still cannot get how can .action become /bla/bla
--
Frans Thamura
Meruvian
redefining civilization
http://www.meruvian.com
Re: [struts] REST vs Original
Posted by Dale Newfield <Da...@Newfield.org>.
Jeromy Evans wrote:
> Unfortunately at the moment you can't mix conventions within the same
> Struts2 webapp. The trouble is the REST plugin overrides a lot of the
> default behaviour rather than augmenting it. Right now if your commit to
> REST conventions it'll apply to the entire webapp. With some effort it
> may be possible to use a CompoundActionMapper to to the mix URL-mapping
> schemes though.
I built something like that, but since I didn't get any response I
didn't contribute it. If anyone would like me to send you this
"NamespaceBasedActionMapper", just ask.
http://www.nabble.com/Re:-URL-questions...Was:--Re:--struts--params-and-staticParams-p14330694.html
-Dale
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: REST vs Original
Posted by Jeromy Evans <je...@blueskyminds.com.au>.
Yes and no.
Yes: The REST plugin uses CodeBehind. If appropriate, CodeBehind will be
replaced by the Convention plugin. SmartURLs is being merged into the
Convention plugin. That's a nice convergence.
No: REST involves more than URL mapping. However, it's not unreasonable
that a single Struts2 webapp should be able to have REST services as
well as standard Struts2 actions, but I don't know of any effort to
allow this at the moment. Dale's NamespaceBasedActionMapper may be part
of the solution?
Frans Thamura wrote:
> hi all
>
> is there a plan for REST, so we can mixed all become one, SmartURL,
> original method and new REST model
> i have hugh code and love to try REST
>
> F
>
> ---------------------------------------------------------------------
> 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: REST vs Original
Posted by Frans Thamura <fr...@meruvian.org>.
hi all
is there a plan for REST, so we can mixed all become one, SmartURL,
original method and new REST model
i have hugh code and love to try REST
F
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: REST vs Original
Posted by mg...@hotmail.com.
Thanks for the link dave
If anyone knows how to get Signore Pontarelli I have a *working* build
script for the smarturl project
Ciao
Martin
----- Original Message -----
Wrom: BLVLMHAALPTCXLYRWTQTIPWIGYOKSTTZRCLBD
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Saturday, January 19, 2008 11:20 AM
Subject: Re: REST vs Original
> --- Martin Gainty <mg...@hotmail.com> wrote:
> > SmartURLs..Are there situations where using action-name based results
are
> > preferable over a declared result?
>
> Sure, if you don't want to configure a result manually.
>
> > Where can I get the source for
> > org.texturemedia.smarturls.SmartURLsConfigurationProvider?
>
> http://code.google.com/p/smarturls-s2/
>
> d.
>
>
> ---------------------------------------------------------------------
> 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: REST vs Original
Posted by Dave Newton <ne...@yahoo.com>.
--- Martin Gainty <mg...@hotmail.com> wrote:
> SmartURLs..Are there situations where using action-name based results are
> preferable over a declared result?
Sure, if you don't want to configure a result manually.
> Where can I get the source for
> org.texturemedia.smarturls.SmartURLsConfigurationProvider?
http://code.google.com/p/smarturls-s2/
d.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: REST vs Original
Posted by Martin Gainty <mg...@hotmail.com>.
SmartURLs..Are there situations where using action-name based results are
preferable over a declared result?
Where can I get the source for
org.texturemedia.smarturls.SmartURLsConfigurationProvider?
Thanks
Martin
----- Original Message -----
From: "Jeromy Evans" <je...@blueskyminds.com.au>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Friday, January 18, 2008 7:28 PM
Subject: Re: REST vs Original
> Hi Frans,
>
> Unfortunately at the moment you can't mix conventions within the same
> Struts2 webapp. The trouble is the REST plugin overrides a lot of the
> default behaviour rather than augmenting it. Right now if your commit to
> REST conventions it'll apply to the entire webapp. With some effort it
> may be possible to use a CompoundActionMapper to to the mix URL-mapping
> schemes though.
>
> It sounds like you're mainly interested in nice URLs...
>
> If you just want nice URLs and not actually REST conventions you may
> prefer the SmartURLs plugin. It's being merged into Struts2.1
> Convention plugin but is available for 2.0 now. It does a lot, but
> generally it provides that actions in packages at
> com.mycompany.actions.bla.BlaAction are available at the URL
> /bla/bla.action and further that the URL /bar/ will execute
> com.mycompany.actions.bla.IndexAction, and so on. If you add blank
> extension handline you get some nice urls: /bla/bla -> bla.BlaAction
>
> If you want search-engine friendly URLs that contain parameters in the
> path there are two options:
> - the RestfulActionMapper in Struts2.0 allows URLs like
> /name1/value1/name2/value2/bla.action where name1 and name2 are
> properties in BlaAction. It can be used with a CompoundActionMapper to
> mix this with the Default action mapping, or
> - the NamedVariablePatternMatcher in Struts2.1 allows action
> namespaces to contain properties. eg. /{state}/{city}/bla.action where
> state and city are properties of the BlaAction
>
> AFAIK, the NamedVariablePatternMatcher can be used with either default
> or REST conventions. It can't be used at the same time as default
> wildcards implementation though (/*blaAction). This feature is
> relatively new and undocumented.
>
> It's enabled like this in struts.xml:
> <bean type="com.opensymphony.xwork2.util.PatternMatcher"
> name="namedVariablePatternMatcher"
> class="com.opensymphony.xwork2.util.NamedVariablePatternMatcher"/>
> <constant name="struts.patternMatcher"
> value="namedVariablePatternMatcher"/>
> <constant name="struts.mapper.alwaysSelectFullNamespace" value="true"/>
>
> And used like this:
> @Namespace("/{country}/{state}")
> public class SuburbController implements ModelDriven<Object> {
> public void String setCountry(String country) ...
> public void String setState(String state)...
> ...
> }
>
> (The class above is a REST-controller model-driven action but it should
> work with normal actions too). At this time (Jan08) I can't recommend
> the NamedVariablePatternMatcher unless you're willing to dive into the
> Struts2 source as issues arise as its quite experimental.
>
> Hope that helps,
> Jeromy Evans
>
> Frans Thamura wrote:
> > hi there
> >
> > i just want to know, how to mixe the code between S2 and with REST under
one
> > container.
> >
> > any idea?
> >
> > or anyone have an example that 'this is the old' and 'this is the REST'
> >
> > still cannot get how can .action become /bla/bla
> >
> >
> > ------------------------------------------------------------------------
> >
> > No virus found in this incoming message.
> > Checked by AVG Free Edition.
> > Version: 7.5.516 / Virus Database: 269.19.6/1230 - Release Date:
17/01/2008 4:59 PM
> >
>
>
> ---------------------------------------------------------------------
> 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: REST vs Original
Posted by Frans Thamura <fr...@meruvian.org>.
On Jan 19, 2008 7:28 AM, Jeromy Evans <je...@blueskyminds.com.au> wrote:
> Hi Frans,
>
> Unfortunately at the moment you can't mix conventions within the same
> Struts2 webapp.
hi there
so what should i do if I am intersting with REST, but have a hugh code
using S2 old way.
i think that is not good to rewrite it all over, this can be months job.
any tips?
F
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: REST vs Original
Posted by Jeromy Evans <je...@blueskyminds.com.au>.
Hi Frans,
Unfortunately at the moment you can't mix conventions within the same
Struts2 webapp. The trouble is the REST plugin overrides a lot of the
default behaviour rather than augmenting it. Right now if your commit to
REST conventions it'll apply to the entire webapp. With some effort it
may be possible to use a CompoundActionMapper to to the mix URL-mapping
schemes though.
It sounds like you're mainly interested in nice URLs...
If you just want nice URLs and not actually REST conventions you may
prefer the SmartURLs plugin. It's being merged into Struts2.1
Convention plugin but is available for 2.0 now. It does a lot, but
generally it provides that actions in packages at
com.mycompany.actions.bla.BlaAction are available at the URL
/bla/bla.action and further that the URL /bar/ will execute
com.mycompany.actions.bla.IndexAction, and so on. If you add blank
extension handline you get some nice urls: /bla/bla -> bla.BlaAction
If you want search-engine friendly URLs that contain parameters in the
path there are two options:
- the RestfulActionMapper in Struts2.0 allows URLs like
/name1/value1/name2/value2/bla.action where name1 and name2 are
properties in BlaAction. It can be used with a CompoundActionMapper to
mix this with the Default action mapping, or
- the NamedVariablePatternMatcher in Struts2.1 allows action
namespaces to contain properties. eg. /{state}/{city}/bla.action where
state and city are properties of the BlaAction
AFAIK, the NamedVariablePatternMatcher can be used with either default
or REST conventions. It can't be used at the same time as default
wildcards implementation though (/*blaAction). This feature is
relatively new and undocumented.
It's enabled like this in struts.xml:
<bean type="com.opensymphony.xwork2.util.PatternMatcher"
name="namedVariablePatternMatcher"
class="com.opensymphony.xwork2.util.NamedVariablePatternMatcher"/>
<constant name="struts.patternMatcher"
value="namedVariablePatternMatcher"/>
<constant name="struts.mapper.alwaysSelectFullNamespace" value="true"/>
And used like this:
@Namespace("/{country}/{state}")
public class SuburbController implements ModelDriven<Object> {
public void String setCountry(String country) ...
public void String setState(String state)...
...
}
(The class above is a REST-controller model-driven action but it should
work with normal actions too). At this time (Jan08) I can't recommend
the NamedVariablePatternMatcher unless you're willing to dive into the
Struts2 source as issues arise as its quite experimental.
Hope that helps,
Jeromy Evans
Frans Thamura wrote:
> hi there
>
> i just want to know, how to mixe the code between S2 and with REST under one
> container.
>
> any idea?
>
> or anyone have an example that 'this is the old' and 'this is the REST'
>
> still cannot get how can .action become /bla/bla
>
>
> ------------------------------------------------------------------------
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.516 / Virus Database: 269.19.6/1230 - Release Date: 17/01/2008 4:59 PM
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org