Petter Måhlén wrote:
Hi,

Hello,

The pattern suggested by Bernard felt like something I wanted to implement,
so I decided to give it a shot using friendly URL:s. But, as far as I can
tell, with Tapestry 4.0, RedirectException doesn't quite do the trick unless
you have an absolute URL.

Yes. I forgot to mention that. I just got so used to use TapestryRedirectException in Tap 3 which always created absolute URLs for me that I forgot :) Anyway. It works the same in Tap 3 and Tap 4 - use absolute URL to get real client redirect.

                RedirectException e = new RedirectException("ListAll.page");
                
                e.printStackTrace(); // just to see where in the Tapestry
framework I was...

Btw. If you use Eclipse, have you tried Sysdeo plugin? It allows you to run webapps in Tomcat directly from within code compiled in Eclipse. What more, you can use breakpoints in your webapp code and debug it as normal application :-) You would not need to inject your code with sysouts and printStackTrace methods then :)

I traced it down to this method in ServletWebRequest:

-------------
    public void forward(String URL)

Yes. Javadoc for forward method in WebRequest interface says:
    /
* Redirects to the indicated URL. If the URL is local, then a forward occurs. Otherwise, a
     * client side redirect is returned to the client browser.
     */
    public void forward(String URL);

So if you specify an absolute URL, Tapestry's behaviour when throwing a
RedirectException changes, so the following method appears to work:

That's right.

-------------
                throw new
RedirectException(cycle.getAbsoluteURL("ListAll.page"));
> Much easier than implementing a RedirectException of your own,

That URL won't work if Friendly URLs (FURLs) are not enabled. Resulting URL will be of form:

http://www.yourdomain.com/yourcontext/ListAll.page

And what if you choose to change extension for your page service to other that '.page' ? I suggest that you use proper ServiceEncoding (via IEngineService getLink(boolean post, Object parameter) method to assure that the obtained URL is always valid.

I think that in that case you should create proper url with PageService.getLink method

but perhaps a little bit non-obvious that the semantics of throwing a 
RedirectException
depends on the URL.

Er well. RedirectException is just a messenger ;-) WebRequest does the trick. But I would be nice if Javadoc @see would point to WebRequest forward method.

Hence this post, if someone else wants to do something
similar.

:-)


/ Petter

Bernard

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to