Re: Adding a dynamic sub directory to URL 

2012-07-19 Thread Lance Java
Consider a site with the following url rewriting

/mysite/cars/view - view all cars
/mysite/cars/bmw/view - set the Car environmental as bmw then invoke
/mysite/cars/view
/mysite/cars/porsche/view - set the Car environmental as porsche then
invoke /mysite/cars/view
/mysite/facebook/cars/view - put facebook into the Mode environmental
(different css) then invoke /mysite/cars/view
/mysite/facebook/cars/bmw/view - put facebook into the Mode environmental
and bmw into the Car environmental then invoke /mysite/cars/view

There's two approaches:
1. Cloak the Request in a filter, all processes further down the request
processing pipeline will see a cloaked Request when the @Inject it
2. Only cloak the request when calculating ComponentEventRequestParameters
and PageRenderRequestParameters (decodeComponentEventRequest() and
decodePageRenderRequest())

In option 1:
- The URL displayed in the user's browser will be different to the @Injected
request's getPath()
- I can only assume that the HTTPServletRequest will not be cloaked so
@Inject HTTPServletRequest and @Inject Request will have conflicting path
values
- If I wanted to calculate the relative location of /mysite/ based on
Request.getPath(). I would get the calculation wrong in some cases since the
cloaked Request.getPath() is exactly the same for all URLs (mentioned above)

In option 2:
- The URL displayed in the user's browser is the same as Request.getPath()
- Request and HTTPServletRequest are not in conflict over the value of path
- I will be able to accurately calculate the relative location of /mysite/
in each URL since the URL is not cloaked.

I'm not sure that this URL calculation is a problem but I don't see a need
to cloak the @Inject'ed Request. For this reason, I lean towards option 2.

--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Adding-a-dynamic-sub-directory-to-URL-tp5714532p5714591.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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



Re: Adding a dynamic sub directory to URL 

2012-07-19 Thread Thiago H de Paula Figueiredo
On Thu, 19 Jul 2012 05:18:39 -0300, Lance Java lance.j...@googlemail.com  
wrote:



In option 1:
- The URL displayed in the user's browser will be different to the  
@Injected request's getPath()


That's exactly the point of URL rewriting! :)


- I can only assume that the HTTPServletRequest will not be cloaked so
@Inject HTTPServletRequest and @Inject Request will have conflicting path
values


Yep, but only Tapestry itself only uses Request, not HttpServletRequest,  
and so should you.



- If I wanted to calculate the relative location of /mysite/ based on
Request.getPath(). I would get the calculation wrong in some cases since  
the cloaked Request.getPath() is exactly the same for all URLs  
(mentioned above)


Why would you need to calculate relative locations? I've been using  
Tapestry 5 since 5.0.4 or 5.0.5 and I never needed to do that. Let  
Tapestry do that for you.



In option 2:
- The URL displayed in the user's browser is the same as  
Request.getPath()


So there's no URL rewriting anymore.

I'm not sure that this URL calculation is a problem but I don't see a  
need to cloak the @Inject'ed Request. For this reason, I lean towards  
option 2.


Option number 2 has the same problem as LinkTransformer API: you need to  
decorate or advise ComponentEventLinkEncoder, specifically the decode*()  
methods, so can't use them in your URL rewriting logic for parsing URLs  
and you end up doing that yourself.


--
Thiago H. de Paula Figueiredo

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



Re: Adding a dynamic sub directory to URL

2012-07-18 Thread Dusko Jovanovski
Take a look at http://tynamo.org/tapestry-routing+guide

It's a tynamo module written for this purpose.

On Wed, Jul 18, 2012 at 3:04 AM, dkeenan david_siedle...@yahoo.co.ukwrote:

 This looks perfect! Tapestry is outstandingly good.



 --
 View this message in context:
 http://tapestry.1045711.n5.nabble.com/Adding-a-dynamic-sub-directory-to-URL-tp5714532p5714537.html
 Sent from the Tapestry - User mailing list archive at Nabble.com.

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




Re: Adding a dynamic sub directory to URL 

2012-07-18 Thread Lance Java
I have written a sample application which takes a URL of the form
http://host:port/context/mode/foo/bar and transforms it to
http://host:port/context/foo/bar;. It also sets a Mode environmental to
contain the mode. This environmental can then be accessed in pages and
components. In your case, the mode is similar to your club.

I do this by decorating the ComponentEventLinkEncoder as I found that the
LinkTransformer API was not adequate.

https://github.com/uklance/tapestry-sandbox/blob/master/src/main/java/com/github/uklance/mode/ModeComponentEventLinkEncoder.java
https://github.com/uklance/tapestry-sandbox/blob/master/src/main/java/com/github/uklance/services/AppModule.java#L133

Cheers,
Lance.

--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Adding-a-dynamic-sub-directory-to-URL-tp5714532p5714543.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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



Re: Adding a dynamic sub directory to URL 

2012-07-18 Thread Thiago H de Paula Figueiredo
On Wed, 18 Jul 2012 04:58:31 -0300, Lance Java lance.j...@googlemail.com  
wrote:



I do this by decorating the ComponentEventLinkEncoder as I found that the
LinkTransformer API was not adequate.


I really need to take some time to get the old URL rewriter API, which is  
better suited than LinkTransformer in some scenarios like this in the  
Maven central repository, but somehow it isn't.. I've already adapted it  
to Tapestry 5.3.x and made it into a separate package. If anyone wants to  
grab its sources, check https://github.com/thiagohp/tapestry-url-rewriter.


Cheers!

--
Thiago H. de Paula Figueiredo

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



Re: Adding a dynamic sub directory to URL 

2012-07-18 Thread Lance Java
 If anyone wants to grab its sources, check
https://github.com/thiagohp/tapestry-url-rewriter. 
Peeking at the code, it looks like you needed to decorate
ComponentEventLinkEncoder too

Whatever happens, we need access to the core behaviour so that we can
perform some string manipulation on it. The LinkTransformet API does not
provide this (from what I can see).

--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Adding-a-dynamic-sub-directory-to-URL-tp5714532p5714552.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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



Re: Adding a dynamic sub directory to URL 

2012-07-18 Thread Thiago H de Paula Figueiredo
On Wed, 18 Jul 2012 10:31:51 -0300, Lance Java lance.j...@googlemail.com  
wrote:



If anyone wants to grab its sources, check

https://github.com/thiagohp/tapestry-url-rewriter.
Peeking at the code, it looks like you needed to decorate
ComponentEventLinkEncoder too


It does, but just for outgoing links (the ones generated by Tapestry  
itself). For the incoming ones (requested URLs), it works by changing the  
Request object that is passed through the Tapestry pipelines, so  
ComponentEventLinkEncoder never sees the original requested URL, just the  
rewritten one.


--
Thiago H. de Paula Figueiredo

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



Re: Adding a dynamic sub directory to URL 

2012-07-18 Thread Lance Java
 For the incoming ones (requested URLs), it works by changing the Request
Yes, I saw that... I'm not sure I agree with that approach. If a downstram
process was trying to calculate URL's relative to the current path (to send
to the browser), it would get the calculation wrong.

--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Adding-a-dynamic-sub-directory-to-URL-tp5714532p5714567.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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



Re: Adding a dynamic sub directory to URL 

2012-07-18 Thread Thiago H de Paula Figueiredo
On Wed, 18 Jul 2012 13:17:51 -0300, Lance Java lance.j...@googlemail.com  
wrote:



For the incoming ones (requested URLs), it works by changing the Request
Yes, I saw that... I'm not sure I agree with that approach. If a  
downstram process


Example please. :)

was trying to calculate URL's relative to the current path (to send to  
the browser), it would get the calculation wrong.


Actually, that's the opposite, as all them look at the same Request.  
Believe me, it works, it's used a lot in production sites and it's the  
same URL rewriting code we had in Tapestry itself until 5.1.0.5, just  
adapted to run in 5.3.x. In addition, if you have an incoming URL  
transformation, you probably need an outgoing one too that does the  
reverse.


--
Thiago H. de Paula Figueiredo

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



Adding a dynamic sub directory to URL 

2012-07-17 Thread dkeenan
Hi folks. I am writing a web app to be used by a number of clubs. Each club
can register and create a gallery page and a contact page. Both pages will
then be public. 

I each clubs pages to be viewable from the following urls:

http://localhost/club_url_friendly_name/gallery
http://localhost/club_url_friendly_name/contact

When someone browse to either of the urls the app uses the first part of the
path (club_url_friendly_name) to set the appropriate club in the session and
show the appropriate club page. 

Basically I want to give the impression that each club has its own sub-dir
in the application.

Does anyone know if there is a way of achieving this?

Many thanks,

David. 


--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Adding-a-dynamic-sub-directory-to-URL-tp5714532.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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



Re: Adding a dynamic sub directory to URL 

2012-07-17 Thread Taha Siddiqi
Hi

You should take a look at Tapestry's LinkTransformer API

http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/linktransform/LinkTransformer.html

Here is more than helpful Igor's post

http://blog.tapestry5.de/index.php/2010/09/06/new-url-rewriting-api/


regards
Taha

On Jul 18, 2012, at 6:03 AM, dkeenan wrote:

 Hi folks. I am writing a web app to be used by a number of clubs. Each club
 can register and create a gallery page and a contact page. Both pages will
 then be public. 
 
 I each clubs pages to be viewable from the following urls:
 
 http://localhost/club_url_friendly_name/gallery
 http://localhost/club_url_friendly_name/contact
 
 When someone browse to either of the urls the app uses the first part of the
 path (club_url_friendly_name) to set the appropriate club in the session and
 show the appropriate club page. 
 
 Basically I want to give the impression that each club has its own sub-dir
 in the application.
 
 Does anyone know if there is a way of achieving this?
 
 Many thanks,
 
 David. 
 
 
 --
 View this message in context: 
 http://tapestry.1045711.n5.nabble.com/Adding-a-dynamic-sub-directory-to-URL-tp5714532.html
 Sent from the Tapestry - User mailing list archive at Nabble.com.
 
 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org
 



Re: Adding a dynamic sub directory to URL 

2012-07-17 Thread dkeenan
Superbe! It looks like I can just use a URL rewriter filter to rewrite my
URLs and pass the club name in as a request param. 

http://urlrewritefilter.googlecode.com/svn/trunk/src/doc/manual/4.0/index.html



--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Adding-a-dynamic-sub-directory-to-URL-tp5714532p5714534.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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



Re: Adding a dynamic sub directory to URL 

2012-07-17 Thread dkeenan
Thanks. Will take a look. 

--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Adding-a-dynamic-sub-directory-to-URL-tp5714532p5714535.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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



Re: Adding a dynamic sub directory to URL 

2012-07-17 Thread dkeenan
This looks perfect! Tapestry is outstandingly good. 



--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Adding-a-dynamic-sub-directory-to-URL-tp5714532p5714537.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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