You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Sebastian Hennebrueder <us...@laliluna.de> on 2009/08/06 12:35:17 UTC

Link encoded twice

Hello,

I supect if the Link doesn't get encoded twice.

Once in LinkImp
public String toRedirectURI()
    {
        return appendAnchor(response.encodeRedirectURL(buildURI()));
    }

and once in
ResponseImpl
public void sendRedirect(Link link) throws IOException
    {
        Defense.notNull(link, "link");

        String redirectURL = encodeRedirectURL(link.toRedirectURI());

        sendRedirect(redirectURL);
    }

I run into this issue, while trying to find out how to return a link to 
an external website

http://tapestry.apache.org/tapestry5/guide/pagenav.html

I cannot create a new LinkImpl as a response is needed here. I don't 
know the code well, but shouldn't the response be removed from the Link 
and the encoding be done only when the redirect is sent?

Or shouldn't the Link be used at all? It is in the internal package. In 
that case, we need to fix the documentation.

-- 
Best Regards / Viele Grüße

Sebastian Hennebrueder
-----
Software Developer and Trainer for Hibernate / Java Persistence
http://www.laliluna.de




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


Re: Link encoded twice (thanks)

Posted by Sebastian Hennebrueder <us...@laliluna.de>.
Thank you to all of you.

Howard Lewis Ship schrieb:
> Object onActionFromUrlresponse() throws Exception {
>   return new URL("http", "www.lailuna.de", "");
> }
> 
> Tapestry can capture the exception, if any, and wrap it as a RuntimeException.
> 
> On Thu, Aug 6, 2009 at 7:08 AM, Sebastian
> Hennebrueder<us...@laliluna.de> wrote:
>> Thiago H. de Paula Figueiredo schrieb:
>>> Em Thu, 06 Aug 2009 07:35:17 -0300, Sebastian Hennebrueder
>>> <us...@laliluna.de> escreveu:
>>>
>>>> Hello,
>>> Hi!
>>>
>>> To redirect to an external URL, all you need to do is to return a
>>> java.net.URL instance from an event handler method.
>>>
>> Hello,
>>
>> I found this solution as well but the code is really not nice. Same is true
>> for an anonymous implementation of Link.
>>
>> Object onActionFromUrlresponse() {
>>                try {
>>                        URL url = new URL("http", "www.laliluna.de", "");
>>                        return url;
>>                } catch (MalformedURLException e) {
>>                        throw new RuntimeException(e);
>>                }
>>        }
>>
>> What about something like this?
>> @Inject
>> private PageRenderLinkSource pageRenderLinkSource;
>>
>> Link link =
>> pageRenderLinkSource.createUrl("http://www.laliluna.de").addParam("foo","foovalue").addParam("bar","barValue").addAnchor("#bla").build();
>>
>> If the community find this useful and tell me the place where to implement
>> the LinkFactory (pageRenderLinkSource is just an idea), I could code this.
>>
>> --
>> Best Regards / Viele Grüße
>>
>> Sebastian Hennebrueder
>> -----
>> Software Developer and Trainer for Hibernate / Java Persistence
>> http://www.laliluna.de
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 
> 
> 



-- 
Best Regards / Viele Grüße

Sebastian Hennebrueder
-----
Software Developer and Trainer for Hibernate / Java Persistence
http://www.laliluna.de



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


Re: Link encoded twice

Posted by Howard Lewis Ship <hl...@gmail.com>.
Object onActionFromUrlresponse() throws Exception {
  return new URL("http", "www.lailuna.de", "");
}

Tapestry can capture the exception, if any, and wrap it as a RuntimeException.

On Thu, Aug 6, 2009 at 7:08 AM, Sebastian
Hennebrueder<us...@laliluna.de> wrote:
> Thiago H. de Paula Figueiredo schrieb:
>>
>> Em Thu, 06 Aug 2009 07:35:17 -0300, Sebastian Hennebrueder
>> <us...@laliluna.de> escreveu:
>>
>>> Hello,
>>
>> Hi!
>>
>> To redirect to an external URL, all you need to do is to return a
>> java.net.URL instance from an event handler method.
>>
> Hello,
>
> I found this solution as well but the code is really not nice. Same is true
> for an anonymous implementation of Link.
>
> Object onActionFromUrlresponse() {
>                try {
>                        URL url = new URL("http", "www.laliluna.de", "");
>                        return url;
>                } catch (MalformedURLException e) {
>                        throw new RuntimeException(e);
>                }
>        }
>
> What about something like this?
> @Inject
> private PageRenderLinkSource pageRenderLinkSource;
>
> Link link =
> pageRenderLinkSource.createUrl("http://www.laliluna.de").addParam("foo","foovalue").addParam("bar","barValue").addAnchor("#bla").build();
>
> If the community find this useful and tell me the place where to implement
> the LinkFactory (pageRenderLinkSource is just an idea), I could code this.
>
> --
> Best Regards / Viele Grüße
>
> Sebastian Hennebrueder
> -----
> Software Developer and Trainer for Hibernate / Java Persistence
> http://www.laliluna.de
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry
Director of Open Source Technology at Formos

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


Re: Link encoded twice

Posted by Sebastian Hennebrueder <us...@laliluna.de>.
Thiago H. de Paula Figueiredo schrieb:
> Em Thu, 06 Aug 2009 07:35:17 -0300, Sebastian Hennebrueder 
> <us...@laliluna.de> escreveu:
> 
>> Hello,
> 
> Hi!
> 
> To redirect to an external URL, all you need to do is to return a 
> java.net.URL instance from an event handler method.
> 
Hello,

I found this solution as well but the code is really not nice. Same is 
true for an anonymous implementation of Link.

Object onActionFromUrlresponse() {
		try {
			URL url = new URL("http", "www.laliluna.de", "");
			return url;
		} catch (MalformedURLException e) {
			throw new RuntimeException(e);
		}
	}

What about something like this?
@Inject
private PageRenderLinkSource pageRenderLinkSource;

Link link = 
pageRenderLinkSource.createUrl("http://www.laliluna.de").addParam("foo","foovalue").addParam("bar","barValue").addAnchor("#bla").build();

If the community find this useful and tell me the place where to 
implement the LinkFactory (pageRenderLinkSource is just an idea), I 
could code this.

-- 
Best Regards / Viele Grüße

Sebastian Hennebrueder
-----
Software Developer and Trainer for Hibernate / Java Persistence
http://www.laliluna.de



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


Re: Link encoded twice

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Thu, 06 Aug 2009 07:35:17 -0300, Sebastian Hennebrueder  
<us...@laliluna.de> escreveu:

> Hello,

Hi!

To redirect to an external URL, all you need to do is to return a  
java.net.URL instance from an event handler method.

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

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


Re: Link encoded twice

Posted by Otho <ta...@googlemail.com>.
You read that?

http://wiki.apache.org/tapestry/Tapestry5LinkingToNonTapestryURIs

2009/8/6 Sebastian Hennebrueder <us...@laliluna.de>

> Hello,
>
> I supect if the Link doesn't get encoded twice.
>
> Once in LinkImp
> public String toRedirectURI()
>   {
>       return appendAnchor(response.encodeRedirectURL(buildURI()));
>   }
>
> and once in
> ResponseImpl
> public void sendRedirect(Link link) throws IOException
>   {
>       Defense.notNull(link, "link");
>
>       String redirectURL = encodeRedirectURL(link.toRedirectURI());
>
>       sendRedirect(redirectURL);
>   }
>
> I run into this issue, while trying to find out how to return a link to an
> external website
>
> http://tapestry.apache.org/tapestry5/guide/pagenav.html
>
> I cannot create a new LinkImpl as a response is needed here. I don't know
> the code well, but shouldn't the response be removed from the Link and the
> encoding be done only when the redirect is sent?
>
> Or shouldn't the Link be used at all? It is in the internal package. In
> that case, we need to fix the documentation.
>
> --
> Best Regards / Viele Grüße
>
> Sebastian Hennebrueder
> -----
> Software Developer and Trainer for Hibernate / Java Persistence
> http://www.laliluna.de
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>