You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by kamiseq <ka...@gmail.com> on 2009/12/08 00:38:17 UTC

t5 handling events by components, event handling sequence

hi,
I ve wrote simple component that renders link and handles event triggered by
the link then it sets some value and should render that value.

the problem is that I get the value but then the value is lost as tapestry
redirects to a page that holds the component
Tabs is the page that renders TabNavigation component
[DEBUG] pages.Tabs @PageAttached
[DEBUG] components.TabNavigation got panel3
[INFO] AppModule.TimingFilter Request time: 18 ms
[DEBUG] pages.Tabs @PageDetached
127.0.0.1 -  -  [07/gru/2009:23:20:18 +0000] "GET
/generator/tabs.tabnavigation.tabselect/panel3 HTTP/1.1" 302 0 "
http://localhost:8080/generator/tabs.......
[DEBUG] pages.Tabs @PageAttached
[DEBUG] components.TabContainer @beginRender sets enivromental
[DEBUG] components.TabContainer @BeforeRenderTemplate idtabcontainer
[DEBUG] components.TabNavigation used null
[DEBUG] components.TabPane tabpane@SetupRender fancy=sfssf
[DEBUG] components.TabPane tabpane@SetupRender fancy=sfssf
[DEBUG] components.TabPane tabpane@SetupRender fancy=sfssf
[DEBUG] components.TabContainer @AfterRenderTemplate
[INFO] AppModule.TimingFilter Request time: 19 ms
[DEBUG] pages.Tabs @PageDetached
127.0.0.1 -  -  [07/gru/2009:23:20:18 +0000] "GET /generator/tabs HTTP/1.1"
200 611 "http://localhost:8080/generator/tabs" "Mozilla/5.0 ...

why is so and how can design my component to fix that. Of course I can
annotate the value field as @Persist-ent but I really would like to avoid
session as much as possible. Maybe I could set actionLink to point to Tabs
page instead of TabNavigation component and then assign value to
TabNavigation that will render correctly or some better way to sort that
out.

thanks for any advise
cheers

pozdrawiam
Paweł Kamiński

kamiseq@gmail.com
pkaminski.prv@gmail.com
______________________

Re: t5 handling events by components, event handling sequence

Posted by kamiseq <ka...@gmail.com>.
Ok,
but how can I command the component to render actionLink as a link to the
page that contains the component or how could I redirect from component to
the page in generic way(Could I pass any reference of the page as
component's parameter? and then use public method on that page?)? any way to
intercept the component event??

the big trouble is that component logic is processed first and then tapestry
redirect and renders the page, it should bubble from component to page
without redirecting.


pozdrawiam
Paweł Kamiński

kamiseq@gmail.com
pkaminski.prv@gmail.com
______________________

Re: t5 handling events by components, event handling sequence

Posted by DH <ni...@gmail.com>.
In your case, I think the best practice is to handle the event in the page but not the component. Or you can handle event in the component to perform common logic, then trigger another event and carry relevant data, so for the page, it can handle the second event to do somehing to change its activation context.

DH
http://www.gaonline.com.cn

----- Original Message ----- 
From: "kamiseq" 
To: <us...@tapestry.apache.org>
Sent: Tuesday, December 08, 2009 7:38 AM
Subject: t5 handling events by components, event handling sequence


hi,
I ve wrote simple component that renders link and handles event triggered by
the link then it sets some value and should render that value.

the problem is that I get the value but then the value is lost as tapestry
redirects to a page that holds the component
Tabs is the page that renders TabNavigation component
[DEBUG] pages.Tabs @PageAttached
[DEBUG] components.TabNavigation got panel3
[INFO] AppModule.TimingFilter Request time: 18 ms
[DEBUG] pages.Tabs @PageDetached
127.0.0.1 -  -  [07/gru/2009:23:20:18 +0000] "GET
/generator/tabs.tabnavigation.tabselect/panel3 HTTP/1.1" 302 0 "
http://localhost:8080/generator/tabs.......
[DEBUG] pages.Tabs @PageAttached
[DEBUG] components.TabContainer @beginRender sets enivromental
[DEBUG] components.TabContainer @BeforeRenderTemplate idtabcontainer
[DEBUG] components.TabNavigation used null
[DEBUG] components.TabPane tabpane@SetupRender fancy=sfssf
[DEBUG] components.TabPane tabpane@SetupRender fancy=sfssf
[DEBUG] components.TabPane tabpane@SetupRender fancy=sfssf
[DEBUG] components.TabContainer @AfterRenderTemplate
[INFO] AppModule.TimingFilter Request time: 19 ms
[DEBUG] pages.Tabs @PageDetached
127.0.0.1 -  -  [07/gru/2009:23:20:18 +0000] "GET /generator/tabs HTTP/1.1"
200 611 "http://localhost:8080/generator/tabs" "Mozilla/5.0 ...

why is so and how can design my component to fix that. Of course I can
annotate the value field as @Persist-ent but I really would like to avoid
session as much as possible. Maybe I could set actionLink to point to Tabs
page instead of TabNavigation component and then assign value to
TabNavigation that will render correctly or some better way to sort that
out.

thanks for any advise
cheers

pozdrawiam
Paweł Kamiński

kamiseq@gmail.com
pkaminski.prv@gmail.com
______________________

Re: t5 handling events by components, event handling sequence

Posted by kamiseq <ka...@gmail.com>.
>
> I beg to differ. The framework itself does not use the session. If you're
> using an onActivate()/onPassivate() method pair, you don't need to persist
> the corresponding fields.

ActionLink and EventLink preserve the page context as long as you provide it
> to the context parameter.
>

After your post I made a small example again and this time it started to
work without any passing context values to component or persisting context
at page's level. I really dont know why I had so strange behaviours before
and cannot reproduce them...... maybe I misspelled the onPasivate  .... or
something I really cant tell now. maybe I spent to much time on that before
and was to tired to see the bug.....

anyway it works as it should be and how I wanted :) it to work so please
accept my apologise about all bad things I said about framework :-) now it
rocks ;] and I am really happy that finally I got the thing

pozdrawiam
Paweł Kamiński

kamiseq@gmail.com
pkaminski.prv@gmail.com
______________________

Re: t5 handling events by components, event handling sequence

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Wed, 09 Dec 2009 15:34:52 -0200, kamiseq <ka...@gmail.com> escreveu:

> The session itself is extremely overused in the framework and it could be
> limited if only actionLink's call preserve page's context.

I beg to differ. The framework itself does not use the session. If you're  
using an onActivate()/onPassivate() method pair, you don't need to persist  
the corresponding fields. ActionLink and EventLink preserve the page  
context as long as you provide it to the context parameter.

By the way, when using redirect-after-post, any framework would need some  
session use to hold values between an action request and the subsequent  
render request.

-- 
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: t5 handling events by components, event handling sequence

Posted by kamiseq <ka...@gmail.com>.
>
>  I don't understand what's your problem. Page activation context would
>> always be kept between any requests of the same page, if you add the context
>> that given to the tab component tot he page activation conetext, and provide
>> the correct onActivate and onPassivate handler, there would be no problem at
>> all. Everything should work.
>>
>
> with onPasivate() you are totally right although it forces to set
additional context value and onPassivate() at each page that uses the
controller and contextfield needs to be @persist-ed in session. Contrary to
that when you pass context value(s), while in page's onActive(..) , to
component and then redirect with *pagerender.createPageRenderLinkWithContext
* then at least the field can be persisted using flash type and you dont
need additional code.

Everything right, as long as the context value is passed to the tab
> component.
> It seems to me that the tab state is not preserved between requests.
>
>
yes it is not, and what I noticed is that when using onPassivate then the
action link gets ?t.ac=context_value so someone there has been thinking
about that but went wrong way :| (at least in my opinion)
The session itself is extremely overused in the framework and it could be
limited if only actionLink's call preserve page's context.

that are my thoughts about that and maybe I just think in wrong way....
-- 

pozdrawiam
Paweł Kamiński

kamiseq@gmail.com
pkaminski.prv@gmail.com
______________________

Re: t5 handling events by components, event handling sequence

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Wed, 09 Dec 2009 12:44:31 -0200, ningdh <ni...@gmail.com> escreveu:

> I don't understand what's your problem. Page activation context would  
> always be kept between any requests of the same page, if you add the  
> context that given to the tab component tot he page activation conetext,  
> and provide the correct onActivate and onPassivate handler, there would  
> be no problem at all. Everything should work.

Everything right, as long as the context value is passed to the tab  
component.
It seems to me that the tab state is not preserved between requests.

-- 
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: t5 handling events by components, event handling sequence

Posted by ningdh <ni...@gmail.com>.
I don't understand what's your problem. Page activation context would always be kept between any requests of the same page, if you add the context that given to the tab component tot he page activation conetext, and provide the correct onActivate and onPassivate handler, there would be no problem at all. Everything should work.

 DH

----- Original Message ----- 
From: "kamiseq" <ka...@gmail.com>
To: "Tapestry users" <us...@tapestry.apache.org>
Sent: Wednesday, December 09, 2009 6:40 PM
Subject: Re: t5 handling events by components, event handling sequence


yes eventually I did so
*BUT* answering your question, it -in my opinion- how tab component renders
doesn't depend on page context, because it just groups/organise content of
the page and if removed page remains unchanged. component model depends on
context but it is given by page and component is not aware where it came
from.

the context is needed here just to preserve the original context of the page
that contains the component. so if tapestry rendered the actionLink from
component like
*/myapp/user/1/index.tabnavigation.tabselect/tabVersions* and then redirect
to page using original context */myapp/user/1 *there wouldnt be a problem.
but it doesnt and you need pass additional values.

maybe I am missing something here so if someone can clarify all this I would
appreciate.


2009/12/9 Geoff Callender <ge...@gmail.com>

> Why don't you want to pass the page's context to the tab component? Isn't
> the content of the tabs dependent on the value of the page's context?
>
> On 09/12/2009, at 4:46 AM, kamiseq wrote:
>
> > ok one more thing, my tabs are working great but let examine such a
> usecase
> >
> > 1)I have user page with a grid of a user list
> > 2)when user is selected I rerender the page with context specified by
> grid
> > element
> > 3)my url then is something like myapp/user/1 and the tab control is
> > displayed with 3 tabs (for example)
> > 4)when I click a tab event is triggered to component and then it
> redirects
> > back to the page to rerender its context and here where the problem
> occurs
> > cos the link is incorrect and the initial selection is lost
> >
> > I figured out something like in tab component
> >
> > @Inject
> > private PageRenderLinkSource pagerender;
> > @Inject
> > private ComponentResources resources;
> >
> > @OnEvent(component = "tabSelect")
> > Object onTabActivated(String panelId) {
> >    this.activeTabInfo = new TabInfo(panelId);
> > *    return
> >
> pagerender.createPageRenderLinkWithContext(this.resources.getPage().getClass(),
> > ??);*
> > }
> >
> > and if I replace "??" with the initial context value (let say "1"
> everything
> > works fine - the question is where to get the initial page's context
> from.
> >
> > maybe I can aquire it as well from ComponentResources as it seams that
> > framework knows about it
> > [INFO] AppModule.TimingFilter Request time: 3 ms
> > 127.0.0.1 -  -  [08/gru/2009:17:15:06 +0000]
> > "GET*/myapp/user/index.tabnavigation.tabselect/tabVersions HTTP/1.1"
> > *302 0 *"http://localhost:8080/myapp/user/1"
> > ..
> > *127.0.0.1 -  -  [08/gru/2009:17:15:06 +0000]* "GET /myapp/user
> > HTTP/1.1"*200 1954
> > * "http://localhost:8080/myapp/user/1"*
> >
> > the page's Long onPasivate() doesn't help so I am a bit stuck here, and I
> > dont want to pass page's context value to tab component
> >
> > pozdrawiam
> > Paweł Kamiński
> >
> > kamiseq@gmail.com
> > pkaminski.prv@gmail.com
> > ______________________
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 

pozdrawiam
Paweł Kamiński

kamiseq@gmail.com
pkaminski.prv@gmail.com
______________________

Re: t5 handling events by components, event handling sequence

Posted by kamiseq <ka...@gmail.com>.
yes eventually I did so
*BUT* answering your question, it -in my opinion- how tab component renders
doesn't depend on page context, because it just groups/organise content of
the page and if removed page remains unchanged. component model depends on
context but it is given by page and component is not aware where it came
from.

the context is needed here just to preserve the original context of the page
that contains the component. so if tapestry rendered the actionLink from
component like
*/myapp/user/1/index.tabnavigation.tabselect/tabVersions* and then redirect
to page using original context */myapp/user/1 *there wouldnt be a problem.
but it doesnt and you need pass additional values.

maybe I am missing something here so if someone can clarify all this I would
appreciate.


2009/12/9 Geoff Callender <ge...@gmail.com>

> Why don't you want to pass the page's context to the tab component? Isn't
> the content of the tabs dependent on the value of the page's context?
>
> On 09/12/2009, at 4:46 AM, kamiseq wrote:
>
> > ok one more thing, my tabs are working great but let examine such a
> usecase
> >
> > 1)I have user page with a grid of a user list
> > 2)when user is selected I rerender the page with context specified by
> grid
> > element
> > 3)my url then is something like myapp/user/1 and the tab control is
> > displayed with 3 tabs (for example)
> > 4)when I click a tab event is triggered to component and then it
> redirects
> > back to the page to rerender its context and here where the problem
> occurs
> > cos the link is incorrect and the initial selection is lost
> >
> > I figured out something like in tab component
> >
> > @Inject
> > private PageRenderLinkSource pagerender;
> > @Inject
> > private ComponentResources resources;
> >
> > @OnEvent(component = "tabSelect")
> > Object onTabActivated(String panelId) {
> >    this.activeTabInfo = new TabInfo(panelId);
> > *    return
> >
> pagerender.createPageRenderLinkWithContext(this.resources.getPage().getClass(),
> > ??);*
> > }
> >
> > and if I replace "??" with the initial context value (let say "1"
> everything
> > works fine - the question is where to get the initial page's context
> from.
> >
> > maybe I can aquire it as well from ComponentResources as it seams that
> > framework knows about it
> > [INFO] AppModule.TimingFilter Request time: 3 ms
> > 127.0.0.1 -  -  [08/gru/2009:17:15:06 +0000]
> > "GET*/myapp/user/index.tabnavigation.tabselect/tabVersions HTTP/1.1"
> > *302 0 *"http://localhost:8080/myapp/user/1"
> > ..
> > *127.0.0.1 -  -  [08/gru/2009:17:15:06 +0000]* "GET /myapp/user
> > HTTP/1.1"*200 1954
> > * "http://localhost:8080/myapp/user/1"*
> >
> > the page's Long onPasivate() doesn't help so I am a bit stuck here, and I
> > dont want to pass page's context value to tab component
> >
> > pozdrawiam
> > Paweł Kamiński
> >
> > kamiseq@gmail.com
> > pkaminski.prv@gmail.com
> > ______________________
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 

pozdrawiam
Paweł Kamiński

kamiseq@gmail.com
pkaminski.prv@gmail.com
______________________

Re: t5 handling events by components, event handling sequence

Posted by Geoff Callender <ge...@gmail.com>.
Why don't you want to pass the page's context to the tab component? Isn't the content of the tabs dependent on the value of the page's context?

On 09/12/2009, at 4:46 AM, kamiseq wrote:

> ok one more thing, my tabs are working great but let examine such a usecase
> 
> 1)I have user page with a grid of a user list
> 2)when user is selected I rerender the page with context specified by grid
> element
> 3)my url then is something like myapp/user/1 and the tab control is
> displayed with 3 tabs (for example)
> 4)when I click a tab event is triggered to component and then it redirects
> back to the page to rerender its context and here where the problem occurs
> cos the link is incorrect and the initial selection is lost
> 
> I figured out something like in tab component
> 
> @Inject
> private PageRenderLinkSource pagerender;
> @Inject
> private ComponentResources resources;
> 
> @OnEvent(component = "tabSelect")
> Object onTabActivated(String panelId) {
>    this.activeTabInfo = new TabInfo(panelId);
> *    return
> pagerender.createPageRenderLinkWithContext(this.resources.getPage().getClass(),
> ??);*
> }
> 
> and if I replace "??" with the initial context value (let say "1" everything
> works fine - the question is where to get the initial page's context from.
> 
> maybe I can aquire it as well from ComponentResources as it seams that
> framework knows about it
> [INFO] AppModule.TimingFilter Request time: 3 ms
> 127.0.0.1 -  -  [08/gru/2009:17:15:06 +0000]
> "GET*/myapp/user/index.tabnavigation.tabselect/tabVersions HTTP/1.1"
> *302 0 *"http://localhost:8080/myapp/user/1"
> ..
> *127.0.0.1 -  -  [08/gru/2009:17:15:06 +0000]* "GET /myapp/user
> HTTP/1.1"*200 1954
> * "http://localhost:8080/myapp/user/1"*
> 
> the page's Long onPasivate() doesn't help so I am a bit stuck here, and I
> dont want to pass page's context value to tab component
> 
> pozdrawiam
> Paweł Kamiński
> 
> kamiseq@gmail.com
> pkaminski.prv@gmail.com
> ______________________


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


Re: t5 handling events by components, event handling sequence

Posted by kamiseq <ka...@gmail.com>.
ok one more thing, my tabs are working great but let examine such a usecase

1)I have user page with a grid of a user list
2)when user is selected I rerender the page with context specified by grid
element
3)my url then is something like myapp/user/1 and the tab control is
displayed with 3 tabs (for example)
4)when I click a tab event is triggered to component and then it redirects
back to the page to rerender its context and here where the problem occurs
cos the link is incorrect and the initial selection is lost

I figured out something like in tab component

@Inject
private PageRenderLinkSource pagerender;
@Inject
private ComponentResources resources;

@OnEvent(component = "tabSelect")
Object onTabActivated(String panelId) {
    this.activeTabInfo = new TabInfo(panelId);
*    return
pagerender.createPageRenderLinkWithContext(this.resources.getPage().getClass(),
??);*
}

and if I replace "??" with the initial context value (let say "1" everything
works fine - the question is where to get the initial page's context from.

maybe I can aquire it as well from ComponentResources as it seams that
framework knows about it
[INFO] AppModule.TimingFilter Request time: 3 ms
127.0.0.1 -  -  [08/gru/2009:17:15:06 +0000]
"GET*/myapp/user/index.tabnavigation.tabselect/tabVersions HTTP/1.1"
*302 0 *"http://localhost:8080/myapp/user/1"
..
*127.0.0.1 -  -  [08/gru/2009:17:15:06 +0000]* "GET /myapp/user
HTTP/1.1"*200 1954
* "http://localhost:8080/myapp/user/1"*

the page's Long onPasivate() doesn't help so I am a bit stuck here, and I
dont want to pass page's context value to tab component

pozdrawiam
Paweł Kamiński

kamiseq@gmail.com
pkaminski.prv@gmail.com
______________________

Re: t5 handling events by components, event handling sequence

Posted by kamiseq <ka...@gmail.com>.
yep
I am just after huge argument with my firend about tapestry and wishes vs
reality :)
now I understand and it makes some sense although I try to avoid @persist as
much as possible

and the main problem here is to define how user must use the page and
interact with it and what if session expires / he/she redirects to another
page and comes back to the first one. I need to think about those at first
place

thanks for help

pozdrawiam
Paweł Kamiński

kamiseq@gmail.com
pkaminski.prv@gmail.com
______________________

Re: t5 handling events by components, event handling sequence

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Mon, 07 Dec 2009 21:38:17 -0200, kamiseq <ka...@gmail.com> escreveu:

> hi,

Hi!

> I ve wrote simple component that renders link and handles event  
> triggered by
> the link then it sets some value and should render that value.
> the problem is that I get the value but then the value is lost as  
> tapestry redirects to a page that holds the component
> why is so and how can design my component to fix that. Of course I can
> annotate the value field as @Persist-ent but I really would like to avoid
> session as much as possible.

You cannot avoid the session in this case, as Tapestry uses  
redirect-after-post. You can use @Persist("flash"): the value will be  
removed from the session after it is read the first time.

-- 
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