struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Don Brown" <donald.br...@gmail.com>
Subject Re: Struts Equiv to RoR's controller, action, id
Date Fri, 21 Apr 2006 22:24:37 GMT
If you combine DispatchAction [1] with wildcards introduced in Struts 1.2,
you can do something very similar:

<action
    path="/*/*"
    type="foo.bar.{1}Controller"
    parameter="{2}">
    <forward
        name="success"
        path="/{1}/{2}.jsp"/>
</action>

Then in Struts 1.3, we added the ability to pass multiple values to your
action, rather than just one through the "parameter" attribute, which takes
you the rest of the way:

<action
    path="/*/*/*"
    type="foo.bar.{1}Controller"
    parameter="{2}">
    <set-property key="id" value="{3}" />
    <forward
        name="success"
        path="/{1}/{2}.jsp"/>
</action>

Don

[1]
http://www.jroller.com/page/mrdon?entry=simplifying_struts_dispatchaction_and_wildcards

On 4/21/06, Frank W. Zammetti <fzlists@omnytex.com> wrote:
>
> Hi Ben,
>
> I'm not familiar with RoR, but from what you describe here it sounds
> like what you want is a DispatchActon, or probably more specifically,
> the EventDispatchAction introduced in Struts 1.2.9:
>
>
> http://struts.apache.org/struts-doc-1.2.9/api/org/apache/struts/actions/EventDispatchAction.html
>
> Frank
>
> ben.christenson wrote:
> > Hello all,
> >
> > I am relatively new to stuts, and reading madly trying to absorb enough
> to
> > become proficient.  I have worked a bit with Ruby on Rails, and like
> quite a
> > few of their paradigms, however Ruby is far from an accepted solution
> for
> > the company I work with.  One of the things I really liked about Ruby on
> > Rails was their concept of a controller/action/id.  Is there a way in
> struts
> > to use part of the url to define what method to use and a
> parameter?  For
> > example, if I wanted to retrieve information on a company with id=001, I
> > would like to use the url
> > http://www.mywebsitehere.com/companies/getcompany/001.
> >
> > Thanks,
> > Ben
> > --
> > View this message in context:
> http://www.nabble.com/Struts-Equiv-to-RoR%27s-controller%2C-action%2C-id-t1489136.html#a4034695
> > Sent from the Struts - User forum at Nabble.com.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
> >
> >
>
> --
> Frank W. Zammetti
> Founder and Chief Software Architect
> Omnytex Technologies
> http://www.omnytex.com
> AIM: fzammetti
> Yahoo: fzammetti
> MSN: fzammetti@hotmail.com
> Java Web Parts -
> http://javawebparts.sourceforge.net
> Supplying the wheel, so you don't have to reinvent it!
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

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