You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Nomen Nominus <ge...@outlook.com> on 2013/08/01 21:18:53 UTC

RE: Index broken reference

Hi Thiago!
My code handles properly all event URL's, however not in the following scenario:
localhost ( this is index page ) and it can't handle any event url from there, however, in all
other scenarios ( for instance if I type localhost/about in my browser bar, it gets me to about page, and from there every event link works just fine ). To be more clear to you, here is the matrix of scenarios and is as follows:

localhost/about -> localhost ( works )
localhost/about -> localhost/contact ( works )
localhost/* -> localhost/* ( works, where * denotes any page )
localhost -> localhost/* ( doesn't work )

Also, how could I change to ComponentEventLinkEncoder, change what?

> To: users@tapestry.apache.org
> Subject: Re: Index broken reference
> Date: Mon, 29 Jul 2013 07:56:18 -0300
> From: thiagohp@gmail.com
> 
> On Sun, 28 Jul 2013 17:15:08 -0300, Nomen Nominus <ge...@outlook.com>  
> wrote:
> 
> > My code for links is just fine, and I see no reason why it's not working  
> > in the one case, and works in the next.
> 
> Your Dispatcher may not be working in 100% of the situations.
> 
> > Maybe, following code is
> > public class ProtectPageService implements Dispatcher {
> 
> Dispatchers are supposed to return content in requests. This is not the  
> case here, so you can write a Dispatcher and make it work, but writing a  
> RequestFilter would be more adequate
> 
> >
> >     private final static String LOGIN_PAGE = "/";
> >     private ApplicationStateManager applicationStateManager;
> >     private final ComponentClassResolver componentClassResolver;
> >     private final ComponentSource componentSource;
> >
> >     public ProtectPageService(ApplicationStateManager asm,  
> > ComponentClassResolver resolver, ComponentSource componentSource) {
> >         this.applicationStateManager = asm;
> >         this.componentClassResolver = resolver;
> >         this.componentSource = componentSource;
> >     }
> >
> >     public boolean dispatch(Request request, Response response) throws  
> > IOException {
> >         /*
> >          * We need to get the Tapestry page requested by the user. So we  
> > parse the path extracted from the request
> >          */
> 
> You're trying to parse URLs yourself. That's a bad idea: First, you don't  
> need to: the ComponentEventLinkEncoder service and its decode() methods  
> already do that for you. That's exactly what Tapestry itself uses. Second,  
> *your code* is probably not handling event URLs correctly. Just change it  
> to using ComponentEventLinkEncoder and it'll work.
> 
> -- 
> Thiago H. de Paula Figueiredo
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
 		 	   		  

Re: Index broken reference

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Thu, 01 Aug 2013 16:18:53 -0300, Nomen Nominus <ge...@outlook.com>  
wrote:

> Hi Thiago!

Hi!

> My code handles properly all event URL's, however not in the following  
> scenario:

So it doesn't handles all scenarios. :) You're contradicting yourself in a  
single sentence. :P

> Also, how could I change to ComponentEventLinkEncoder, change what?

Just inject it and Request and use the ComponentEventLinkEncoder.decode()  
methods instead of your URl parsing code. They'll tell you, in their  
return values, what page was requested. Again, don't implement something  
that is already implemented. You're just wasting your time in this case.

>
>> To: users@tapestry.apache.org
>> Subject: Re: Index broken reference
>> Date: Mon, 29 Jul 2013 07:56:18 -0300
>> From: thiagohp@gmail.com
>>
>> On Sun, 28 Jul 2013 17:15:08 -0300, Nomen Nominus  
>> <ge...@outlook.com>
>> wrote:
>>
>> > My code for links is just fine, and I see no reason why it's not  
>> working
>> > in the one case, and works in the next.
>>
>> Your Dispatcher may not be working in 100% of the situations.
>>
>> > Maybe, following code is
>> > public class ProtectPageService implements Dispatcher {
>>
>> Dispatchers are supposed to return content in requests. This is not the
>> case here, so you can write a Dispatcher and make it work, but writing a
>> RequestFilter would be more adequate
>>
>> >
>> >     private final static String LOGIN_PAGE = "/";
>> >     private ApplicationStateManager applicationStateManager;
>> >     private final ComponentClassResolver componentClassResolver;
>> >     private final ComponentSource componentSource;
>> >
>> >     public ProtectPageService(ApplicationStateManager asm,
>> > ComponentClassResolver resolver, ComponentSource componentSource) {
>> >         this.applicationStateManager = asm;
>> >         this.componentClassResolver = resolver;
>> >         this.componentSource = componentSource;
>> >     }
>> >
>> >     public boolean dispatch(Request request, Response response) throws
>> > IOException {
>> >         /*
>> >          * We need to get the Tapestry page requested by the user. So  
>> we
>> > parse the path extracted from the request
>> >          */
>>
>> You're trying to parse URLs yourself. That's a bad idea: First, you  
>> don't
>> need to: the ComponentEventLinkEncoder service and its decode() methods
>> already do that for you. That's exactly what Tapestry itself uses.  
>> Second,
>> *your code* is probably not handling event URLs correctly. Just change  
>> it
>> to using ComponentEventLinkEncoder and it'll work.
>>
>> --
>> Thiago H. de Paula Figueiredo
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>  		 	   		


-- 
Thiago H. de Paula Figueiredo

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