Em Thu, 05 Feb 2009 14:17:32 -0300, xfile80303 <l...@grokers.net> escreveu:

Greetings all,

Hello! :)

Specifically, I would like to manipulate the URLs such that I can have
"nice" RESTful style URLs which feed information into the page ultimately
being rendered.

Tapestry is incredibly RESTful, so I guess you don't have to do much to accomplish what you want. :)

For example:
/app/venue_name/en_US/category/product/UUID
where product would be the rendering page, UUID could be the activation
context (which, if I understand correctly T5 will handle already). However, the "venue_name" and locale are not actual pages and are simply information which is to be gleaned from the URL and passed to the page so it can render as specified.

All you need to do is to ignore the venue_name and locale parameters. thedailytube.com, a website created by some guy in this list I always forget the name (I'm sorry . . .), does what you need in the video pages. Look at this URL:

http://www.thedailytube.com/video/15794/christian-bales-freak-out-remix

The video page uses the first parameter (15794) as the id of the video to be shown. The second parameter is there just for search engine purposes. Try http://www.thedailytube.com/video/15794/tapestry5rules. It gives you exactly the same page as the original URL. ;)

As other posts have suggested, it would seem to me that any manipulation of the URL would have to happen in such a way that Tapestry would properly 1) parse these URL "parameters" and pass them into the system for use by the
page,

One advice is to use EventContext. It is a little hard to find in the documentation (EventContext section in http://tapestry.apache.org/tapestry5/guide/event.html), but any event handler method, including onActivate(), can have a single EventContext parameter. It provides you two methods: one with the parameter count, other that returns the value of the n-th parameter. Having an onActivate(EventContext context) method makes it really easy to deal with different parameters in the activation context, even optional parameters.



and 2) understand these "parameters" would need to be in Tapestry
generated links to preserve this data from link to link (page to page).

There has been mention of using a RequestFilter or a Dispatcher to do this, but I have two concerns with this: 1) I am not sure how I would modify the Request (at all?) so Tapestry internals would find the page to render
(remove the venu_name and locale parameters and let Tapestry locate the
category/product page)

As stated above, you don't need to change the request, just ignore the parameters you don't need.

2) Even if I was able to modify the Request, how
would I accomplish #2 above, so generated links would contain this data?

That's the hard part here. One solution is to remember to add the parameters in the context of all PageLinks. Remember: the activation context can have parameters that will be ignored. In this case, the activation context would be a List, not a single value Most examples use an id as the activation context, but that's not the only way to do it. A more automated solution could be the decoration of the LinkFactory service to automatically add the parameters. I haven't tested it, though.

--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to