struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mraible <m...@raibledesigns.com>
Subject Re: Using the Restful2ActionMapper
Date Wed, 15 Aug 2007 22:25:50 GMT

I'm trying to change from using the old-style URLs to Restful2ActionMapper.
Here's what I've added to struts.xml:

    <bean name="struts2"
type="org.apache.struts2.dispatcher.mapper.ActionMapper"
class="org.apache.struts2.dispatcher.mapper.CompositeActionMapper"/>
    <constant name="struts.mapper.composite"
value="org.apache.struts2.dispatcher.mapper.DefaultActionMapper,org.apache.struts2.dispatcher.mapper.Restful2ActionMapper"/>

I have a UserAction that does CRUD (below).

And the following action definitions:

        <!-- List of Users -->
        <action name="users" class="userAction" method="list">
            <result name="success">userList.jsp</result>
            <result name="input">userList.jsp</result>
        </action>

        <!-- Edit User -->
        <action name="editUser" class="userAction" method="edit">
            <result name="success">userForm.jsp</result>
            <result name="input">userList.jsp</result>
        </action>

        <!-- Save User -->
        <action name="saveUser" class="userAction">
            <result name="cancel" type="redirect">users.html</result>
            <result name="delete" type="redirect">users.html</result>
            <result name="input">userForm.jsp</result>
            <result name="success"
type="chain">saveUserWithValidation</result>
        </action>

        <action name="saveUserWithValidation" class="userAction"
method="save">
            <result name="input">userForm.jsp</result>
            <result name="success" type="redirect">users.html</result>
        </action>

Is it possible to change to something like the following?

  <action name="user/*" className="userAction">
    {0}
    ...
  </action>

If so, I'm guessing I need to change some method names (i.e. the default
method for /user would be index, so I should change list() to index()) and
some result names (edit goes to "edit", save goes to "save", index goes to
"success")?

Thanks,

Matt


Philip Lorenz-2 wrote:
> 
> 
>> 
>> Tomorrow's task for me is trying RESTful, so hopefully
>> you'll figure this out ;)
>> 
>> Do you need the ".action" in the URL?!
>> 
>> d.
> 
> You can remove the action postfix by setting struts.action.extension to an
> empty string. I just left it enabled to have a clean default config with
> only the neccesary settings changed.
> 
> Philip
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Using-the-Restful2ActionMapper-tf3173361.html#a12171692
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


Mime
View raw message