You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jan Jirout <ji...@coroptis.com> on 2010/01/30 22:58:34 UTC

problem with component

Hi All,

I have strange problem with URL rewriting. I'm changing path name in 
URLRewriterRule. In following way:

      public Request process(Request request, URLRewriteContext context) {
              return new SimpleRequestWrapper(request, "somePath");
      }

It works fine. Problem is with page context in case of component events. 
If component event with some context is passed into previous 
URLRewriterRule then page context is lost. Only way how to avoid this 
problem is following adjustment:

      public Request process(Request request, URLRewriteContext context) {
          if (context.getPageParameters() == null) {
            /**
             * it's component event
             */
            return request;
          }
          return new SimpleRequestWrapper(request, "somePath");
      }


In this case component events are not processed so context is preserved. 
Problem is that component event URLs are not adjusted. Even following 
example lost component event context.

      public Request process(Request request, URLRewriteContext context) {
              return new SimpleRequestWrapper(request, request.getPath());
      }

Do you have any clue how to process component events without lost context?

thanks

Jan

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


Re: problem with component

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Thu, 04 Feb 2010 11:37:05 -0200, Jan Jirout <ji...@coroptis.com> wrote:

> Hi,

Hi!

> I'll try change implementation of ComponentEventLinkEncoderMethodAdvice,  
> it seems to me that it could help. I don't fully understand T5 so I  
> don't know if it's bug or not. What do you think?

This is a bug. Please file a JIRA for that.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da  
Informação Ltda.
http://www.arsmachina.com.br

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


Re: problem with component

Posted by Jan Jirout <ji...@coroptis.com>.
Hi,

thanks for looking at this, it really helps me. I think that I found 
place where is forForm changed to wrong value, let me describe it:

It seems that LinkImpl is correctly created in 
ComponentEventLinkEncoderImpl at 194 with forForm=true. Next is 
ComponentEventLinkEncoderMethodAdvice#advice called. There is created 
"fakeRequest". This "fakeRequest" is then passed through all registered 
URLRewriterRule implementations and rewrited request is returned. If 
"fakeRequest" and rewritten request are not same then LinkImpl is 
rewritten. This is the place where is the problem, LinkImpl rewriting 
code is:

            newLink = new LinkImpl(newUrl, false, false, response, null);

so the rewritten link have always forForm=false. And this is the problem.

I'll try change implementation of ComponentEventLinkEncoderMethodAdvice, 
it seems to me that it could help. I don't fully understand T5 so I 
don't know if it's bug or not. What do you think?

regards

Jan


Josh Canfield wrote:
> I should add that
>
>   
>> SimpleRequestWrapper fakeRequest = new SimpleRequestWrapper(request,
>> link.toAbsoluteURI());
>>     
>
> comes from ComponentEventLinkEncoderMethodAdvice#rewriteIfNeeded
>
> On Mon, Feb 1, 2010 at 9:20 PM, Josh Canfield <jo...@gmail.com> wrote:
>   
>> Ok, I found the problem.
>> The form action is created like so:
>> void beginRender(MarkupWriter writer)
>>    {
>>        Link link =
>> resources.createFormEventLink(EventConstants.ACTION, context);
>>
>> It then pulls the query parameters from the link and sticks them into
>> hidden fields. The problem is that when you rewrite a url the first
>> thing it does is converts the link toAbsoluteURI
>>
>> SimpleRequestWrapper fakeRequest = new SimpleRequestWrapper(request,
>> link.toAbsoluteURI());
>>
>> which drops the containing the page context (t:ac) because it's in the
>> links parameters, and the link is for a form.
>> From LinkImpl:
>> private String buildURI()
>>    {
>>        if (forForm || parameters == null)
>>            return absoluteURI;
>> ...
>>
>>
>> So, the form is built without the page context...
>>
>> Seems mildly suspicious that the link knows it's for a form. The
>> javadoc says: "Query parameters are never added to a forForm link."
>> But I'm not coming up with a good reason why... if the form want's to
>> treat the query params special then shouldn't it strip them off?
>>
>> Josh
>>
>>
>>
>> On Sun, Jan 31, 2010 at 5:45 AM, Jan Jirout <ji...@coroptis.com> wrote:
>>     
>>> Hi,
>>>
>>> This is really code that I'm running. I really hope that I'm not wrong about
>>> that. Code that I posted shouldn't affected result of filter. I'm using
>>> tapestry version 5.1.0.5. I added simple project demonstrating the problem.
>>>
>>> In attachment is example application demonstrating that SimpleRequestWrapper
>>> in my case somehow change the request.
>>>
>>> Let me closely describe used use case. I have component Discussion, this
>>> discussion is used at different king of pages. In object Discussion there
>>> should be inject object implementing ActionRemote. When user submit new
>>> comment is called ActionRemote.onAction(CommentForm form). Injecting of
>>> concrete ActionRemote implementation is done in main page (User) during
>>> executing onActivate phase.
>>>
>>> In attached example, there are two ways how to demonstrate problem:
>>>    * start application by "mvn jetty:run" and then access User page and
>>> submit filled form. And you'll see exception saying that page context is
>>> missing.
>>>    * try to run test case UserTest.testSubmitForm() and you'll see same
>>> exception
>>>
>>> I hope, that attached example will works in yours environment. Please try to
>>> look at my example, it's possible that I doing something wrong.
>>>
>>> Jan
>>>
>>> Josh Canfield wrote:
>>>       
>>>>> I tried to use following code:
>>>>>
>>>>>   public Request process(Request request, URLRewriteContext context) {
>>>>>           return new SimpleRequestWrapper(request, request.getPath());
>>>>>   }
>>>>>
>>>>> When I use this code then context of component event is even lost. I
>>>>> didn't
>>>>> find way how to create SimpleRequestWrapper with component even context.
>>>>>
>>>>>           
>>>> This is surprising. I hate to ask, but are you really sure this is the
>>>> code that is running? What you have here should be the equivalent to
>>>> doing nothing. What version of tapestry are you using?
>>>>
>>>>
>>>> Josh
>>>>
>>>> On Sat, Jan 30, 2010 at 2:56 PM, Jan Jirout <ji...@coroptis.com> wrote:
>>>>
>>>>         
>>>>> Hi,
>>>>>
>>>>> thanks for answer.
>>>>>
>>>>> In my real application I change just pieces of path but it didn't work.
>>>>>
>>>>> I tried to use following code:
>>>>>
>>>>>   public Request process(Request request, URLRewriteContext context) {
>>>>>           return new SimpleRequestWrapper(request, request.getPath());
>>>>>   }
>>>>>
>>>>> When I use this code then context of component event is even lost. I
>>>>> didn't
>>>>> find way how to create SimpleRequestWrapper with component even context.
>>>>>
>>>>> Just in case when I call "return request;" from "process" method is
>>>>> component event context correctly passed.
>>>>>
>>>>> If you would like to see example application I can send it to conference.
>>>>>
>>>>> regards
>>>>>
>>>>> Jan
>>>>>
>>>>>
>>>>> Thiago H. de Paula Figueiredo wrote:
>>>>>
>>>>>           
>>>>>> On Sat, 30 Jan 2010 19:58:34 -0200, Jan Jirout <ji...@coroptis.com>
>>>>>> wrote:
>>>>>>
>>>>>>
>>>>>>             
>>>>>>> Hi All,
>>>>>>>
>>>>>>>               
>>>>>> Hi!
>>>>>>
>>>>>>
>>>>>>             
>>>>>>> I have strange problem with URL rewriting. I'm changing path name in
>>>>>>> URLRewriterRule. In following way:
>>>>>>>
>>>>>>>     public Request process(Request request, URLRewriteContext context)
>>>>>>> {
>>>>>>>             return new SimpleRequestWrapper(request, "somePath");
>>>>>>>     }
>>>>>>>
>>>>>>>               
>>>>>> The above rule rewrites *all* URLs to "somePath", losing any context or
>>>>>> query parameters. You should use string manipulation to extract the
>>>>>> original
>>>>>> page name and then replace it with the new page name.
>>>>>>
>>>>>> If a request to "/original/1 arrives", your should rewrite it to
>>>>>> "/new/1".
>>>>>> You can use path.replace("/original/", "/new/") to do that, for example.
>>>>>>
>>>>>>
>>>>>>             
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>
>>>>>
>>>>>
>>>>>           
>>>>
>>>>
>>>>         
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>       
>>
>> --
>> --
>> http://www.bodylabgym.com - a private, by appointment only, one-on-one
>> health and fitness facility.
>> --
>> http://www.ectransition.com - Quality Electronic Cigarettes at a
>> reasonable price!
>> --
>> TheDailyTube.com. Sign up and get the best new videos on the internet
>> delivered fresh to your inbox.
>>
>>     
>
>
>
>   


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


Re: problem with component

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, 02 Feb 2010 03:22:38 -0200, Josh Canfield <jo...@gmail.com>  
wrote:

> I should add that
>
>> SimpleRequestWrapper fakeRequest = new SimpleRequestWrapper(request,
>> link.toAbsoluteURI());
>
> comes from ComponentEventLinkEncoderMethodAdvice#rewriteIfNeeded

I can't recall is there's a JIRA for that. If not, please post one. This  
should be corrected.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da  
Informação Ltda.
http://www.arsmachina.com.br

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


Re: problem with component

Posted by Josh Canfield <jo...@gmail.com>.
I should add that

> SimpleRequestWrapper fakeRequest = new SimpleRequestWrapper(request,
> link.toAbsoluteURI());

comes from ComponentEventLinkEncoderMethodAdvice#rewriteIfNeeded

On Mon, Feb 1, 2010 at 9:20 PM, Josh Canfield <jo...@gmail.com> wrote:
> Ok, I found the problem.
> The form action is created like so:
> void beginRender(MarkupWriter writer)
>    {
>        Link link =
> resources.createFormEventLink(EventConstants.ACTION, context);
>
> It then pulls the query parameters from the link and sticks them into
> hidden fields. The problem is that when you rewrite a url the first
> thing it does is converts the link toAbsoluteURI
>
> SimpleRequestWrapper fakeRequest = new SimpleRequestWrapper(request,
> link.toAbsoluteURI());
>
> which drops the containing the page context (t:ac) because it's in the
> links parameters, and the link is for a form.
> From LinkImpl:
> private String buildURI()
>    {
>        if (forForm || parameters == null)
>            return absoluteURI;
> ...
>
>
> So, the form is built without the page context...
>
> Seems mildly suspicious that the link knows it's for a form. The
> javadoc says: "Query parameters are never added to a forForm link."
> But I'm not coming up with a good reason why... if the form want's to
> treat the query params special then shouldn't it strip them off?
>
> Josh
>
>
>
> On Sun, Jan 31, 2010 at 5:45 AM, Jan Jirout <ji...@coroptis.com> wrote:
>> Hi,
>>
>> This is really code that I'm running. I really hope that I'm not wrong about
>> that. Code that I posted shouldn't affected result of filter. I'm using
>> tapestry version 5.1.0.5. I added simple project demonstrating the problem.
>>
>> In attachment is example application demonstrating that SimpleRequestWrapper
>> in my case somehow change the request.
>>
>> Let me closely describe used use case. I have component Discussion, this
>> discussion is used at different king of pages. In object Discussion there
>> should be inject object implementing ActionRemote. When user submit new
>> comment is called ActionRemote.onAction(CommentForm form). Injecting of
>> concrete ActionRemote implementation is done in main page (User) during
>> executing onActivate phase.
>>
>> In attached example, there are two ways how to demonstrate problem:
>>    * start application by "mvn jetty:run" and then access User page and
>> submit filled form. And you'll see exception saying that page context is
>> missing.
>>    * try to run test case UserTest.testSubmitForm() and you'll see same
>> exception
>>
>> I hope, that attached example will works in yours environment. Please try to
>> look at my example, it's possible that I doing something wrong.
>>
>> Jan
>>
>> Josh Canfield wrote:
>>>>
>>>> I tried to use following code:
>>>>
>>>>   public Request process(Request request, URLRewriteContext context) {
>>>>           return new SimpleRequestWrapper(request, request.getPath());
>>>>   }
>>>>
>>>> When I use this code then context of component event is even lost. I
>>>> didn't
>>>> find way how to create SimpleRequestWrapper with component even context.
>>>>
>>>
>>> This is surprising. I hate to ask, but are you really sure this is the
>>> code that is running? What you have here should be the equivalent to
>>> doing nothing. What version of tapestry are you using?
>>>
>>>
>>> Josh
>>>
>>> On Sat, Jan 30, 2010 at 2:56 PM, Jan Jirout <ji...@coroptis.com> wrote:
>>>
>>>>
>>>> Hi,
>>>>
>>>> thanks for answer.
>>>>
>>>> In my real application I change just pieces of path but it didn't work.
>>>>
>>>> I tried to use following code:
>>>>
>>>>   public Request process(Request request, URLRewriteContext context) {
>>>>           return new SimpleRequestWrapper(request, request.getPath());
>>>>   }
>>>>
>>>> When I use this code then context of component event is even lost. I
>>>> didn't
>>>> find way how to create SimpleRequestWrapper with component even context.
>>>>
>>>> Just in case when I call "return request;" from "process" method is
>>>> component event context correctly passed.
>>>>
>>>> If you would like to see example application I can send it to conference.
>>>>
>>>> regards
>>>>
>>>> Jan
>>>>
>>>>
>>>> Thiago H. de Paula Figueiredo wrote:
>>>>
>>>>>
>>>>> On Sat, 30 Jan 2010 19:58:34 -0200, Jan Jirout <ji...@coroptis.com>
>>>>> wrote:
>>>>>
>>>>>
>>>>>>
>>>>>> Hi All,
>>>>>>
>>>>>
>>>>> Hi!
>>>>>
>>>>>
>>>>>>
>>>>>> I have strange problem with URL rewriting. I'm changing path name in
>>>>>> URLRewriterRule. In following way:
>>>>>>
>>>>>>     public Request process(Request request, URLRewriteContext context)
>>>>>> {
>>>>>>             return new SimpleRequestWrapper(request, "somePath");
>>>>>>     }
>>>>>>
>>>>>
>>>>> The above rule rewrites *all* URLs to "somePath", losing any context or
>>>>> query parameters. You should use string manipulation to extract the
>>>>> original
>>>>> page name and then replace it with the new page name.
>>>>>
>>>>> If a request to "/original/1 arrives", your should rewrite it to
>>>>> "/new/1".
>>>>> You can use path.replace("/original/", "/new/") to do that, for example.
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>
>
>
> --
> --
> http://www.bodylabgym.com - a private, by appointment only, one-on-one
> health and fitness facility.
> --
> http://www.ectransition.com - Quality Electronic Cigarettes at a
> reasonable price!
> --
> TheDailyTube.com. Sign up and get the best new videos on the internet
> delivered fresh to your inbox.
>



-- 
--
http://www.bodylabgym.com - a private, by appointment only, one-on-one
health and fitness facility.
--
http://www.ectransition.com - Quality Electronic Cigarettes at a
reasonable price!
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.

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


Re: problem with component

Posted by Josh Canfield <jo...@gmail.com>.
Ok, I found the problem.
The form action is created like so:
void beginRender(MarkupWriter writer)
    {
        Link link =
resources.createFormEventLink(EventConstants.ACTION, context);

It then pulls the query parameters from the link and sticks them into
hidden fields. The problem is that when you rewrite a url the first
thing it does is converts the link toAbsoluteURI

SimpleRequestWrapper fakeRequest = new SimpleRequestWrapper(request,
link.toAbsoluteURI());

which drops the containing the page context (t:ac) because it's in the
links parameters, and the link is for a form.
>From LinkImpl:
private String buildURI()
    {
        if (forForm || parameters == null)
            return absoluteURI;
...


So, the form is built without the page context...

Seems mildly suspicious that the link knows it's for a form. The
javadoc says: "Query parameters are never added to a forForm link."
But I'm not coming up with a good reason why... if the form want's to
treat the query params special then shouldn't it strip them off?

Josh



On Sun, Jan 31, 2010 at 5:45 AM, Jan Jirout <ji...@coroptis.com> wrote:
> Hi,
>
> This is really code that I'm running. I really hope that I'm not wrong about
> that. Code that I posted shouldn't affected result of filter. I'm using
> tapestry version 5.1.0.5. I added simple project demonstrating the problem.
>
> In attachment is example application demonstrating that SimpleRequestWrapper
> in my case somehow change the request.
>
> Let me closely describe used use case. I have component Discussion, this
> discussion is used at different king of pages. In object Discussion there
> should be inject object implementing ActionRemote. When user submit new
> comment is called ActionRemote.onAction(CommentForm form). Injecting of
> concrete ActionRemote implementation is done in main page (User) during
> executing onActivate phase.
>
> In attached example, there are two ways how to demonstrate problem:
>    * start application by "mvn jetty:run" and then access User page and
> submit filled form. And you'll see exception saying that page context is
> missing.
>    * try to run test case UserTest.testSubmitForm() and you'll see same
> exception
>
> I hope, that attached example will works in yours environment. Please try to
> look at my example, it's possible that I doing something wrong.
>
> Jan
>
> Josh Canfield wrote:
>>>
>>> I tried to use following code:
>>>
>>>   public Request process(Request request, URLRewriteContext context) {
>>>           return new SimpleRequestWrapper(request, request.getPath());
>>>   }
>>>
>>> When I use this code then context of component event is even lost. I
>>> didn't
>>> find way how to create SimpleRequestWrapper with component even context.
>>>
>>
>> This is surprising. I hate to ask, but are you really sure this is the
>> code that is running? What you have here should be the equivalent to
>> doing nothing. What version of tapestry are you using?
>>
>>
>> Josh
>>
>> On Sat, Jan 30, 2010 at 2:56 PM, Jan Jirout <ji...@coroptis.com> wrote:
>>
>>>
>>> Hi,
>>>
>>> thanks for answer.
>>>
>>> In my real application I change just pieces of path but it didn't work.
>>>
>>> I tried to use following code:
>>>
>>>   public Request process(Request request, URLRewriteContext context) {
>>>           return new SimpleRequestWrapper(request, request.getPath());
>>>   }
>>>
>>> When I use this code then context of component event is even lost. I
>>> didn't
>>> find way how to create SimpleRequestWrapper with component even context.
>>>
>>> Just in case when I call "return request;" from "process" method is
>>> component event context correctly passed.
>>>
>>> If you would like to see example application I can send it to conference.
>>>
>>> regards
>>>
>>> Jan
>>>
>>>
>>> Thiago H. de Paula Figueiredo wrote:
>>>
>>>>
>>>> On Sat, 30 Jan 2010 19:58:34 -0200, Jan Jirout <ji...@coroptis.com>
>>>> wrote:
>>>>
>>>>
>>>>>
>>>>> Hi All,
>>>>>
>>>>
>>>> Hi!
>>>>
>>>>
>>>>>
>>>>> I have strange problem with URL rewriting. I'm changing path name in
>>>>> URLRewriterRule. In following way:
>>>>>
>>>>>     public Request process(Request request, URLRewriteContext context)
>>>>> {
>>>>>             return new SimpleRequestWrapper(request, "somePath");
>>>>>     }
>>>>>
>>>>
>>>> The above rule rewrites *all* URLs to "somePath", losing any context or
>>>> query parameters. You should use string manipulation to extract the
>>>> original
>>>> page name and then replace it with the new page name.
>>>>
>>>> If a request to "/original/1 arrives", your should rewrite it to
>>>> "/new/1".
>>>> You can use path.replace("/original/", "/new/") to do that, for example.
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>>
>>
>>
>>
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>



-- 
--
http://www.bodylabgym.com - a private, by appointment only, one-on-one
health and fitness facility.
--
http://www.ectransition.com - Quality Electronic Cigarettes at a
reasonable price!
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.

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


Re: problem with component

Posted by Jan Jirout <ji...@coroptis.com>.
Hi,

This is really code that I'm running. I really hope that I'm not wrong 
about that. Code that I posted shouldn't affected result of filter. I'm 
using tapestry version 5.1.0.5. I added simple project demonstrating the 
problem.

In attachment is example application demonstrating that 
SimpleRequestWrapper in my case somehow change the request.

Let me closely describe used use case. I have component Discussion, this 
discussion is used at different king of pages. In object Discussion 
there should be inject object implementing ActionRemote. When user 
submit new comment is called ActionRemote.onAction(CommentForm form). 
Injecting of concrete ActionRemote implementation is done in main page 
(User) during executing onActivate phase.

In attached example, there are two ways how to demonstrate problem:
     * start application by "mvn jetty:run" and then access User page 
and submit filled form. And you'll see exception saying that page 
context is missing.
     * try to run test case UserTest.testSubmitForm() and you'll see 
same exception

I hope, that attached example will works in yours environment. Please 
try to look at my example, it's possible that I doing something wrong.

Jan

Josh Canfield wrote:
>> I tried to use following code:
>>
>>    public Request process(Request request, URLRewriteContext context) {
>>            return new SimpleRequestWrapper(request, request.getPath());
>>    }
>>
>> When I use this code then context of component event is even lost. I didn't
>> find way how to create SimpleRequestWrapper with component even context.
>>     
>
> This is surprising. I hate to ask, but are you really sure this is the
> code that is running? What you have here should be the equivalent to
> doing nothing. What version of tapestry are you using?
>
>
> Josh
>
> On Sat, Jan 30, 2010 at 2:56 PM, Jan Jirout <ji...@coroptis.com> wrote:
>   
>> Hi,
>>
>> thanks for answer.
>>
>> In my real application I change just pieces of path but it didn't work.
>>
>> I tried to use following code:
>>
>>    public Request process(Request request, URLRewriteContext context) {
>>            return new SimpleRequestWrapper(request, request.getPath());
>>    }
>>
>> When I use this code then context of component event is even lost. I didn't
>> find way how to create SimpleRequestWrapper with component even context.
>>
>> Just in case when I call "return request;" from "process" method is
>> component event context correctly passed.
>>
>> If you would like to see example application I can send it to conference.
>>
>> regards
>>
>> Jan
>>
>>
>> Thiago H. de Paula Figueiredo wrote:
>>     
>>> On Sat, 30 Jan 2010 19:58:34 -0200, Jan Jirout <ji...@coroptis.com>
>>> wrote:
>>>
>>>       
>>>> Hi All,
>>>>         
>>> Hi!
>>>
>>>       
>>>> I have strange problem with URL rewriting. I'm changing path name in
>>>> URLRewriterRule. In following way:
>>>>
>>>>      public Request process(Request request, URLRewriteContext context) {
>>>>              return new SimpleRequestWrapper(request, "somePath");
>>>>      }
>>>>         
>>> The above rule rewrites *all* URLs to "somePath", losing any context or
>>> query parameters. You should use string manipulation to extract the original
>>> page name and then replace it with the new page name.
>>>
>>> If a request to "/original/1 arrives", your should rewrite it to "/new/1".
>>> You can use path.replace("/original/", "/new/") to do that, for example.
>>>
>>>       
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>>     
>
>
>
>   


Re: problem with component

Posted by Josh Canfield <jo...@gmail.com>.
> I tried to use following code:
>
>    public Request process(Request request, URLRewriteContext context) {
>            return new SimpleRequestWrapper(request, request.getPath());
>    }
>
> When I use this code then context of component event is even lost. I didn't
> find way how to create SimpleRequestWrapper with component even context.

This is surprising. I hate to ask, but are you really sure this is the
code that is running? What you have here should be the equivalent to
doing nothing. What version of tapestry are you using?


Josh

On Sat, Jan 30, 2010 at 2:56 PM, Jan Jirout <ji...@coroptis.com> wrote:
> Hi,
>
> thanks for answer.
>
> In my real application I change just pieces of path but it didn't work.
>
> I tried to use following code:
>
>    public Request process(Request request, URLRewriteContext context) {
>            return new SimpleRequestWrapper(request, request.getPath());
>    }
>
> When I use this code then context of component event is even lost. I didn't
> find way how to create SimpleRequestWrapper with component even context.
>
> Just in case when I call "return request;" from "process" method is
> component event context correctly passed.
>
> If you would like to see example application I can send it to conference.
>
> regards
>
> Jan
>
>
> Thiago H. de Paula Figueiredo wrote:
>>
>> On Sat, 30 Jan 2010 19:58:34 -0200, Jan Jirout <ji...@coroptis.com>
>> wrote:
>>
>>> Hi All,
>>
>> Hi!
>>
>>> I have strange problem with URL rewriting. I'm changing path name in
>>> URLRewriterRule. In following way:
>>>
>>>      public Request process(Request request, URLRewriteContext context) {
>>>              return new SimpleRequestWrapper(request, "somePath");
>>>      }
>>
>> The above rule rewrites *all* URLs to "somePath", losing any context or
>> query parameters. You should use string manipulation to extract the original
>> page name and then replace it with the new page name.
>>
>> If a request to "/original/1 arrives", your should rewrite it to "/new/1".
>> You can use path.replace("/original/", "/new/") to do that, for example.
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
--
http://www.bodylabgym.com - a private, by appointment only, one-on-one
health and fitness facility.
--
http://www.ectransition.com - Quality Electronic Cigarettes at a
reasonable price!
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.

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


Re: problem with component

Posted by Jan Jirout <ji...@coroptis.com>.
Hi,

thanks for answer.

In my real application I change just pieces of path but it didn't work.

I tried to use following code:

     public Request process(Request request, URLRewriteContext context) {
             return new SimpleRequestWrapper(request, request.getPath());
     }

When I use this code then context of component event is even lost. I 
didn't find way how to create SimpleRequestWrapper with component even 
context.

Just in case when I call "return request;" from "process" method is 
component event context correctly passed.

If you would like to see example application I can send it to conference.

regards

Jan


Thiago H. de Paula Figueiredo wrote:
> On Sat, 30 Jan 2010 19:58:34 -0200, Jan Jirout <ji...@coroptis.com> 
> wrote:
>
>> Hi All,
>
> Hi!
>
>> I have strange problem with URL rewriting. I'm changing path name in 
>> URLRewriterRule. In following way:
>>
>>       public Request process(Request request, URLRewriteContext 
>> context) {
>>               return new SimpleRequestWrapper(request, "somePath");
>>       }
>
> The above rule rewrites *all* URLs to "somePath", losing any context 
> or query parameters. You should use string manipulation to extract the 
> original page name and then replace it with the new page name.
>
> If a request to "/original/1 arrives", your should rewrite it to 
> "/new/1". You can use path.replace("/original/", "/new/") to do that, 
> for example.
>


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


Re: problem with component

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Sat, 30 Jan 2010 19:58:34 -0200, Jan Jirout <ji...@coroptis.com> wrote:

> Hi All,

Hi!

> I have strange problem with URL rewriting. I'm changing path name in  
> URLRewriterRule. In following way:
>
>       public Request process(Request request, URLRewriteContext context)  
> {
>               return new SimpleRequestWrapper(request, "somePath");
>       }

The above rule rewrites *all* URLs to "somePath", losing any context or  
query parameters. You should use string manipulation to extract the  
original page name and then replace it with the new page name.

If a request to "/original/1 arrives", your should rewrite it to "/new/1".  
You can use path.replace("/original/", "/new/") to do that, for example.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da  
Informação Ltda.
http://www.arsmachina.com.br

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


Re: problem with component

Posted by Kristian Marinkovic <kr...@porsche.co.at>.
if you rewrite the URL you have to take care of the context
yourself. 

you could use the PageRenderLinkSource service to 
create a Link with the desired context and return the 
generated url :

Link link = pageLinkSource.createPageRenderLinkWithContext(
        DocumentExportPage.class, "my","context", "values");

return new SimpleRequestWrapper(request, link.toRedirectURI());


g,
kris




Jan Jirout <ji...@coroptis.com> 
30.01.2010 22:58
Bitte antworten an
"Tapestry users" <us...@tapestry.apache.org>


An
Tapestry users <us...@tapestry.apache.org>
Kopie

Thema
problem with component







Hi All,

I have strange problem with URL rewriting. I'm changing path name in 
URLRewriterRule. In following way:

      public Request process(Request request, URLRewriteContext context) {
              return new SimpleRequestWrapper(request, "somePath");
      }

It works fine. Problem is with page context in case of component events. 
If component event with some context is passed into previous 
URLRewriterRule then page context is lost. Only way how to avoid this 
problem is following adjustment:

      public Request process(Request request, URLRewriteContext context) {
          if (context.getPageParameters() == null) {
            /**
             * it's component event
             */
            return request;
          }
          return new SimpleRequestWrapper(request, "somePath");
      }


In this case component events are not processed so context is preserved. 
Problem is that component event URLs are not adjusted. Even following 
example lost component event context.

      public Request process(Request request, URLRewriteContext context) {
              return new SimpleRequestWrapper(request, request.getPath());
      }

Do you have any clue how to process component events without lost context?

thanks

Jan

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