I don't like Dispatcher approach in one reason: using Dispatchers I will have to route incoming requests myself and pick (instantiate?) concrete task handler (and, maybe, manage their state?). In this case using pages is preferred for me. However I also refused to return StreamResponse from onActivate, since keeping onActivate simple is a good approach I think.
For now I ended up with the following: 1. I declared custom metadata symbol (I named it NO_MARKUP) and annotated all task handler pages with this metadata. 2. I contributed markupRenderer as a first renderer in chain and in there I'm checking if page class contatins declared annotation. If it presents, I simply return "<html></html>" as a response. Here's the code in AppModule: /* * Support pages without markup */ private static final String NO_MARKUP_SYMBOL = "NoMarkup"; public static final String NO_MARKUP = NO_MARKUP_SYMBOL + "=true"; public static void contributeFactoryDefaults(MappedConfiguration<String, String> configuration) { configuration.add(NO_MARKUP_SYMBOL, ""); } public void contributeMarkupRenderer(OrderedConfiguration<MarkupRendererFilter> configuration, final MetaDataLocator metaDataLocator, final ComponentEventLinkEncoder linkEncoder, final RequestGlobals globals) { configuration.add(NO_MARKUP_SYMBOL, new MarkupRendererFilter() { @Override public void renderMarkup(MarkupWriter writer, MarkupRenderer renderer) { PageRenderRequestParameters parameters = linkEncoder.decodePageRenderRequest(globals.getRequest()); boolean noMarkup = metaDataLocator.findMeta(NO_MARKUP_SYMBOL, parameters.getLogicalPageName(), Boolean.class); if (noMarkup) { // Provide default (empty) markup writer.element("html"); } else { renderer.renderMarkup(writer); } } }, "before:*"); } and an example of task class declaration: @Meta(AppModule.NO_MARKUP) public abstract class LongRunningQueryTask { Hope this will help somebody else. On Wed, Mar 31, 2010 at 15:44, Thiago H. de Paula Figueiredo < thiag...@gmail.com> wrote: > On Wed, 31 Mar 2010 05:30:49 -0300, Dmitry Gusev <dmitry.gu...@gmail.com> > wrote: > > Can't get it working with Dispatcher. >> > > Take a look at > http://wiki.apache.org/tapestry/Tapestry5HowToCreateADispatcher. > > > Where should I plug new dispatcher >> > > It must be contributed to the MasterDispatcher service. > > > and what should a dispatcher do? >> > > A dispatcher is a class that handles requests and generates a response. In > Tapestry, it's the concept more similar to a servlet. In your case, as you > don't need to generate a response, it would be a better fit than a page. > > > Do you propose to replaces pages with >> dispatchers? >> > > No, just to handle URLs that don't generate a response. > > > Or just make dispatcher which somehow says to Tapestry that >> specified page doesn't contain any template file? >> > > No. A dispatcher is completely different from a page. > > > I tried to add new dispatcher to both "before:PageRender" and >> "after:PageRender" but didn't have any success. The one in >> "after:PageRender" never ever invoked. And handlign request in >> "before:PageRender" prevents executing page's onActivate at all. >> > > In this case, the dispatcher would replace the page that handles the GAE > callback. Don't forget that the boolean dispatch(Request request, Response > response) throws IOException method must return false for requests not > really handled by the dispatcher. > > > -- > Thiago H. de Paula Figueiredo > Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, > and instructor > Owner, software architect and developer, Ars Machina Tecnologia da > Informação Ltda. > http://www.arsmachina.com.br > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > > -- Dmitry Gusev AnjLab Team http://anjlab.com