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);
        }
    }

    protected Resolution GET() {
        throw getException(getContext().getRequest().getMethod());
    }

    protected Resolution POST() {
        throw getException(getContext().getRequest().getMethod());
    }

    protected Resolution PUT() {
        throw getException(getContext().getRequest().getMethod());
    }

    protected Resolution DELETE() {
        throw getException(getContext().getRequest().getMethod());
    }


On Thu, Jul 3, 2008 at 11:55 AM, Nathan Maves <[EMAIL PROTECTED]>
wrote:

> I am just getting into this so excuse my ignorance.
>
>
> I fully understand and use the new URLBinding in 1.5 and love it.
>
> I am trying to find a way to redirect control based on the HTTP request
> type (PUT DELETE ...).  I want to be able to have an action mapping like
> /person which maps to the PersonActionBean which has all for the available
> actions.
>
> What would be the best way to accomplish this in stripes?
>
> Nathan
>

-- 
Ben Gunter
-------------------------------------------------------------------------
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