On 03-07-2008 at 13:58, Ben Gunter wrote:
> I would probably do something like this in a base class and let subclasses
> override the Java methods that correspond to the HTTP methods they want to
> support.
> 
>     protected RuntimeException getException(String method) {
>         return new UnsupportedOperationException("Method " + method + " is
> not supported by "
>                 + getClass());
>     }
> 
>     @DefaultHandler
>     public Resolution execute() {
>         String method = getContext().getRequest().getMethod();
>         if ("GET".equalsIgnoreCase(method)) {
>             return GET();
>         } else if ("POST".equalsIgnoreCase(method)) {
>             return POST();
>         } else if ("PUT".equalsIgnoreCase(method)) {
>             return PUT();
>         } else if ("DELETE".equalsIgnoreCase(method)) {
>             return DELETE();
>         } else {
>             throw getException(method);
>         }
>     }
[...]

For GET and POST this will work. However, Stripes does not call the
ActionBean for the other request methods. So PUT and DELETE will not work.
I assume this is because the HTML specification only allows the use of the
GET and POST HTTP request methods.

To change this, we'd need several changes:
- Binding and validation must now take into account that the request body
  doesn't contain input parameters (like for a POST request), but a binary
  blob that is to be put somewhere. Or alternatively, the InputStream of the
  request is left alone so the programmer can read the request himself (which
  the ActionBeanContext was supposed to abstract away from).
- The DispatcherServlet must re-implement the service() method, to detect the
  request methods HEAD, OPTIONS and TRACE, and direct them to the appropriate
  handler in HttpServlet. Other calls ultimately redirect to doPost(...),
  like GET and POST do mow.

All in all, I'm not certain if this can be done cleanly easily.


Oscar

-- 
   ,-_   So I believe [my version of the truth] until a voice on high
  /() )  says something different. And even then, I'll check to make
 (__ (   sure somebody didn't slip me some really interesting mushrooms
=/  ()   -- just in case.    -- Dark Paladin

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to