Ok, I see. You want one of your activation methods to be called: either the
one with numeric context or the one with string context. As Thiago
suggested, just create an appropriate event context object and pass it.

BTW this can be implemented without the URL rewriting as well. Just provide
an activation method like this and retrieve you string or numeric context
value from passed object.

void onActivate(EventContext context) { ... }

On Wed, Sep 8, 2010 at 8:41 AM, Marek Wawrzyczny <
marek_wawrzyc...@internode.on.net> wrote:

> Hi,
>
> It's quite possibly I'm missing something about the functionality of
> Tapestry or the correct implementation for our problem.
>
> I'm involved in a project where we're porting an existing application to a
> Tapestry based app. The application has been written to respond to several
> URL patterns which hand off the request to appropriate request handlers.
>
> In this particular case, page responds to one of two possible URL
> parameters (but not both), ID (named node) or name. This means that URLs are
> written as either /page/<ID:numeric> or /page/<name:textual>. The Link
> Transformer will have to determine if the parameter passed can be converted
> to an number and based on the result, pass the parameter as either an ID or
> name.
>
> As the legacy application has tonnes of content with the existing content,
> we need to be able to support these in incoming requests.
>
>
> Cheers,
>
> Marek
>
>
> On 08/09/2010, at 16:28, Igor Drobiazko wrote:
>
> > Hi,
> >
> > somehow your description doesn't make sense to me. You are rewriting the
> > incoming URLs like /<app>/page/123 to /<app>/page?id=123. Why actually?
> The
> > incoming request path is a valid page rendering URL. It requests Page
> with
> > activation context 123 to be rendered. Why do you want to transform the
> > activation context to a request parameter? No EventContext will help you
> > because a context is encoded into the URL like /page/123.
> >
> > 2010/9/8 Marek Stanisław Wawrzyczny <marek_wawrzyc...@internode.on.net>
> >
> >> Hi,
> >>
> >> Yes, I'm working with incoming links. The code I have so far:
> >>
> >> public class PageLinkTransformer implements PageRenderLinkTransformer {
> >>
> >>       <...>
> >>
> >>       private static final Pattern REGEX_NODE_PATTERN =
> >> Pattern.compile("/page/(\\d++)");
> >>
> >>       <…>
> >>
> >>       public PageRenderRequestParameters decodePageRenderRequest(Request
> >> request) {
> >>               final String path = request.getPath();
> >>               Matcher matcher = REGEX_NODE_PATTERN.matcher(path);
> >>
> >>               if (matcher.find()) {
> >>                       String node = matcher.group(1);
> >>                       if (node != null) {
> >>                               // TODO: How to inject node number into
> the
> >> new page?
> >>                               PageRenderRequestParameters newRequest =
> new
> >> PageRenderRequestParameters(
> >>                                               "Page", new
> >> EmptyEventContext(), false);
> >>
> >>                               return newRequest;
> >>                       }
> >>               }
> >>               return null;
> >>       }
> >>
> >>       <…>
> >> }
> >>
> >> and the Page itself:
> >>
> >> public class Page {
> >>
> >>       <…>
> >>
> >>       @Property
> >>       @Component(id = "pageTemplate", parameters = {
> "node=currentNode"})
> >>       private PageTemplate pageTemplate;
> >>
> >>       <…>
> >> }
> >>
> >> On 08/09/2010, at 02:57, Igor Drobiazko wrote:
> >>
> >>> Hi,
> >>>
> >>> you need to provide some more details. Are you trying to rewrite
> incoming
> >>> URLs?
> >>>
> >>> 2010/9/7 Marek Stanisław Wawrzyczny <marek_wawrzyc...@internode.on.net
> >
> >>>
> >>>> Hi everyone,
> >>>>
> >>>> I hope you can help a Tapestry newbie here :)
> >>>>
> >>>> I've been following the blog post on how to use the new API (we're
> >>>> developing a new app in 5.2)
> >>>>
> http://blog.tapestry5.de/index.php/2010/09/06/new-url-rewriting-api/but
> >>>> for the life of me I can't figure out how to pass extracted URL
> >> parameters
> >>>> to the new page.
> >>>>
> >>>> So, say we have to rewrite /<app>/page/123 to /<app>/page?id=123, how
> do
> >> I
> >>>> pass the id:123 URL parameter to the EventContext without touching on
> >> any
> >>>> internal classes?
> >>>>
> >>>>
> >>>> Many thanks,
> >>>>
> >>>> Marek Wawrzyczny
> >>>
> >>>
> >>>
> >>>
> >>> --
> >>> Best regards,
> >>>
> >>> Igor Drobiazko
> >>> http://tapestry5.de
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> >> For additional commands, e-mail: users-h...@tapestry.apache.org
> >>
> >>
> >
> >
> > --
> > Best regards,
> >
> > Igor Drobiazko
> > http://tapestry5.de
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


-- 
Best regards,

Igor Drobiazko
http://tapestry5.de

Reply via email to