You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Marcel Sammut <su...@rogers.com> on 2009/12/17 06:50:04 UTC

T5 Page Engine

Greetings,

I'm trying to create an "engine" in tapestry which is capable of determining
which page to display and can also provide parameters.  I currently have a
tapestry 3 application which does this via the old
tapestry.engine.AbstractService.

What I've come across so far is using a Dispatcher which is contributed
before the PageRenderDispatcher that resolves the page name to be displayed
with the parameter values needed.  My web pages will contain links ("<\a
href...") that points to a given url which matches the Dispatchers name.  Of
course, the dispatcher checks the page name and if matches processes and
determines the page name, otherwise normal dispatching occurs.

My problem is when the dispatcher is dispatching a request, how can I
"redirect" to a page and inject objects needed by the page?

My page html:

<\a href="/mywebapp/mydispatcher?someparameter='somevalue'">My Link<\/a>

Java - Tapestry Dispatcher


Public class MyDispatcher implements Dispatcher

  &nbsp;private ComponentSource componentSource;

  &nbsp;Public MyDispatcher(ComponentSource componentSource) {

    &nbsp;&nbsp;this.componentSource = componentSource;

  &nbsp;}

  &nbsp;@Override

  &nbsp;public boolean dispatch(Request request, Response response) throws
IOException {

    &nbsp;&nbsp;String path = request.getPath();

    &nbsp;&nbsp;if ("mydispatcher" == path) {

      &nbsp;&nbsp;&nbsp;&nbsp;String pageName =
functionThatWillGetPageNameFromRequestParameters(request, response);

      &nbsp;&nbsp;&nbsp;&nbsp;Component page =
componentSource.getPage(pageName);

      &nbsp;&nbsp;&nbsp;&nbsp;/****** Want to inject objects/parameters

      &nbsp;&nbsp;&nbsp;&nbsp;******* And render/display this "page"
component [cycle.activate(page) in T3]

    &nbsp;&nbsp;}

    &nbsp;&nbsp;return true;

&nbsp;}

}



I'm not sure if this is the correct approach and am trying to port some T3
applications over to T5.  
Any ideas or thoughts on how to convert a T3 AbstractService would be
useful.

Cheers,

Marcel


-- 
View this message in context: http://old.nabble.com/T5-Page-Engine-tp26823567p26823567.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

Re: T5 Page Engine

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Thu, 17 Dec 2009 03:50:04 -0200, Marcel Sammut <su...@rogers.com>  
escreveu:

> Greetings,

Hello!

Why don't you use URL rewriting for that? Using it, there's no need to do  
redirection, as it happens before the request processing.

-- 
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-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org