Differences between revisions 2 and 3
Revision 2 as of 2007-11-04 00:42:58
Size: 2852
Editor: NickWestgate
Comment:
Revision 3 as of 2009-09-20 23:20:52
Size: 2854
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
[https://issues.apache.org/jira/browse/TAPESTRY-1627 TAPESTRY-1627] A Start page redirect request will produce an empty response if the request URL was root, e.g: http://localhost:8080/myapp/ [[https://issues.apache.org/jira/browse/TAPESTRY-1627|TAPESTRY-1627]] A Start page redirect request will produce an empty response if the request URL was root, e.g: http://localhost:8080/myapp/

A runtime patch for the root path empty response bug

TAPESTRY-1627 A Start page redirect request will produce an empty response if the request URL was root, e.g: http://localhost:8080/myapp/

This is not fixed as of T5.0.6, so if QA is on your back you can patch Tapestry at runtime by adding the code below to your AppModule.

In your AppModule.java file, add the following method

    // TODO: fix for TAPESTRY-1627 - last checked 2007/11/4
    public void contributeMasterDispatcher(
        OrderedConfiguration<Dispatcher> configuration,
        PageRenderRequestHandler pageRenderRequestHandler,
        ComponentClassResolver componentClassResolver,
        @Symbol("tapestry.start-page-name")
        String startPageName,
        @InjectService("PageResponseRenderer")
        PageResponseRenderer pageResponseRenderer)
    {
        class RootPathDispatcherFix implements Dispatcher
        {
            private final ComponentClassResolver _componentClassResolver;

            private final PageRenderRequestHandler _handler;

            @SuppressWarnings("unused")
            private final PageResponseRenderer _renderer;

            private final String _startPageName;

            private final String[] _emptyContext = new String[0];

            public RootPathDispatcherFix(
                final ComponentClassResolver componentClassResolver,
                final PageRenderRequestHandler handler,
                final PageResponseRenderer renderer,
                final String startPageName)
            {
                _componentClassResolver = componentClassResolver;
                _handler = handler;
                _renderer = renderer;
                _startPageName = startPageName;
            }

            public boolean dispatch(Request request, final Response response)
                throws IOException
            {
                // Only match the root path
                if (!request.getPath().equals("/"))
                    return false;
                if (_componentClassResolver.isPageName(_startPageName))
                {
                    ActionResponseGenerator responseGenerator = _handler.handle(_startPageName,
                        _emptyContext);

                    if (responseGenerator != null)
                        responseGenerator.sendClientResponse(response);
                    return true;
                }
                return false;
            }
        }

        // Looks for the root path and renders the start page
        configuration.add("RootPathFix", new RootPathDispatcherFix(componentClassResolver,
            pageRenderRequestHandler, pageResponseRenderer, startPageName), "before:RootPath");
    }

Tapestry5RootPathEmptyResponse (last edited 2009-09-20 23:20:52 by localhost)