You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "olivier dupuy (JIRA)" <ji...@apache.org> on 2008/11/12 20:28:37 UTC

[jira] Created: (WW-2867) Add a method allowing to know what is the name of the "method" passed in the request

Add a method allowing to know what is the name of the "method" passed in the request
------------------------------------------------------------------------------------

                 Key: WW-2867
                 URL: https://issues.apache.org/struts/browse/WW-2867
             Project: Struts 2
          Issue Type: Improvement
          Components: "New" API
    Affects Versions: 2.0.11
         Environment: XP2 Tomcat 5.5 JDK 1.5.0.12
            Reporter: olivier dupuy
            Priority: Minor


Add a method allowing to know what is the name of the "method" passed in the request

Methods can be specified in a form in the JSP, for submit buttons and you can use them in links too.

Add a method in ActionSupport called String getActionmethodName() 
if you submit .... method:save  it would return "save" etc.

I use a an equivalent method to do some security logic in my actions if multiple methods can hit the same action

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (WW-2867) Add a method allowing to know what is the name of the "method" passed in the request

Posted by "James Holmes (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-2867?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

James Holmes updated WW-2867:
-----------------------------

    Fix Version/s: Future

Seems like an interesting proposal. Can you submit a patch to implement this?

> Add a method allowing to know what is the name of the "method" passed in the request
> ------------------------------------------------------------------------------------
>
>                 Key: WW-2867
>                 URL: https://issues.apache.org/struts/browse/WW-2867
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: "New" API
>    Affects Versions: 2.0.11
>         Environment: XP2 Tomcat 5.5 JDK 1.5.0.12
>            Reporter: olivier dupuy
>            Priority: Minor
>             Fix For: Future
>
>
> Add a method allowing to know what is the name of the "method" passed in the request
> Methods can be specified in a form in the JSP, for submit buttons and you can use them in links too.
> Add a method in ActionSupport called String getActionmethodName() 
> if you submit .... method:save  it would return "save" etc.
> I use a an equivalent method to do some security logic in my actions if multiple methods can hit the same action

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (WW-2867) Add a method allowing to know what is the name of the "method" passed in the request

Posted by "olivier dupuy (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-2867?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

olivier dupuy updated WW-2867:
------------------------------

    Attachment: Olivier Dupuy.vcf


Hello James,

Not sure if this is what you ask but here is our code below and I have
no experience of diff since university years.
I have been unable to find a Struts constant corresponding to "method"
but maybe you have one.


If you want to know the use that we have of the method
I have defined a set of interfaces corresponding to events in the UI
e.g.
add button => interface AddAction { public void validateAdd() ; public
void add();}
Save and reset button => interface SaveAction { public void
validateSave() ; public void save();public void validateReset() ; public
void reset();}
....
Basically one interface for each type of event.
Our concrete action class extend a common abstract class where the
method getActionMethodName() is.
Each concrete action class also implements one or more of the interfaces
upper.
This is a very clean solution to normalize all our code, our developers
like it as a good pattern, they know exactly where to look at.

An action implements typically the 4 CRUD operations so we cannot simply
protect in web.xml a URL/action with a role.
We could use different logical names maybe or have the method part of
the URI but we don't so far.
So I need having some security...
As my main abstract action implement Preparable (that we do not use
anywhere else) I use the prepare() method there to intercept all the
calls to look at the action name called. If this is not a method of the
view category (view/select/show..) but a change (add, save, delete,
edit...) then I check it the role of the user with isUserInRole(). So I
have a good single point of control. 

The code below is tested on N7/FF2/FF3/chrome/IE6SP1/IE7 on XP.

Just in case the method name would contain a '.' if this is accepted,
the code could test first if the browser is IE or impersonates before
searching for a '.'

You could put this method in ActionSupport I guess.



Thanks for all the good work on Struts2 BTW, we really enjoy it.

Thanks / Merci
Olivier DUPUY





> Add a method allowing to know what is the name of the "method" passed in the request
> ------------------------------------------------------------------------------------
>
>                 Key: WW-2867
>                 URL: https://issues.apache.org/struts/browse/WW-2867
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: "New" API
>    Affects Versions: 2.0.11
>         Environment: XP2 Tomcat 5.5 JDK 1.5.0.12
>            Reporter: olivier dupuy
>            Priority: Minor
>             Fix For: Future
>
>         Attachments: Olivier Dupuy.vcf
>
>
> Add a method allowing to know what is the name of the "method" passed in the request
> Methods can be specified in a form in the JSP, for submit buttons and you can use them in links too.
> Add a method in ActionSupport called String getActionmethodName() 
> if you submit .... method:save  it would return "save" etc.
> I use a an equivalent method to do some security logic in my actions if multiple methods can hit the same action

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.