You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "angerclown (JIRA)" <de...@tapestry.apache.org> on 2008/02/10 06:14:14 UTC
[jira] Created: (TAPESTRY-2146) Duplicated calls with base class
lifecycle methods
Duplicated calls with base class lifecycle methods
--------------------------------------------------
Key: TAPESTRY-2146
URL: https://issues.apache.org/jira/browse/TAPESTRY-2146
Project: Tapestry
Issue Type: Bug
Components: Core Components
Affects Versions: 5.0.9
Reporter: angerclown
When using a base class with a component, any lifecycle method (pageDetached, pageLoaded, activate, etc) call is duplicated. The core issue seems to be that both the base class and the page class are enhanced to make calls to lifecycle methods and the page class is then calling super.
For example:
package test.base;
public class TestBase {
public void pageDetached() {
System.out.println("Base Detached");
}
}
package test.pages;
public class Test extends TestBase {
@Override
public void pageDetached() {
super.pageDetached();
System.out.println("Detached");
}
}
The output will be:
Base Detached
Detached
Base Detached
Detached
Removing the super.pageDetached() call just outputs Detached twice.
Looking at the source for the both classes (after writing to disk and decompiling with jad):
Base Class
public void containingPageDidDetach()
{
Object obj = null;
pageDetached();
}
Page Class
public void containingPageDidDetach()
{
super.containingPageDidDetach();
Object obj = null;
pageDetached();
}
This is not right since the event is called once for each page. Either 1) the base class should not have these methods enhanced at all or 2) the enchanced page method should not call super. Option 1 seems a little more natural since that would imply you must make super calls in the non-enhanced page classes, i.e. the code you write and expect to call super in anyway. With option 2, there would be more "magic" -- you don't call super in your page detached method, but super.pageDetached gets called anyway by the enhanced class when the event is received.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org
[jira] Closed: (TAPESTRY-2146) Duplicated calls with base class
lifecycle methods
Posted by "Howard M. Lewis Ship (JIRA)" <de...@tapestry.apache.org>.
[ https://issues.apache.org/jira/browse/TAPESTRY-2146?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Howard M. Lewis Ship closed TAPESTRY-2146.
------------------------------------------
Resolution: Won't Fix
Assignee: Howard M. Lewis Ship
Your best bet is to make your lifecycle methods final in the base class. That removes the ambiguity.
> Duplicated calls with base class lifecycle methods
> --------------------------------------------------
>
> Key: TAPESTRY-2146
> URL: https://issues.apache.org/jira/browse/TAPESTRY-2146
> Project: Tapestry
> Issue Type: Bug
> Components: Core Components
> Affects Versions: 5.0.9
> Reporter: angerclown
> Assignee: Howard M. Lewis Ship
>
> When using a base class with a component, any lifecycle method (pageDetached, pageLoaded, activate, etc) call is duplicated. The core issue seems to be that both the base class and the page class are enhanced to make calls to lifecycle methods and the page class is then calling super.
> For example:
> package test.base;
> public class TestBase {
> public void pageDetached() {
> System.out.println("Base Detached");
> }
> }
> package test.pages;
> public class Test extends TestBase {
> @Override
> public void pageDetached() {
> super.pageDetached();
> System.out.println("Detached");
> }
> }
> The output will be:
> Base Detached
> Detached
> Base Detached
> Detached
> Removing the super.pageDetached() call just outputs Detached twice.
> Looking at the source for the both classes (after writing to disk and decompiling with jad):
> Base Class
> public void containingPageDidDetach()
> {
> Object obj = null;
> pageDetached();
> }
> Page Class
> public void containingPageDidDetach()
> {
> super.containingPageDidDetach();
> Object obj = null;
> pageDetached();
> }
> This is not right since the event is called once for each page. Either 1) the base class should not have these methods enhanced at all or 2) the enchanced page method should not call super. Option 1 seems a little more natural since that would imply you must make super calls in the non-enhanced page classes, i.e. the code you write and expect to call super in anyway. With option 2, there would be more "magic" -- you don't call super in your page detached method, but super.pageDetached gets called anyway by the enhanced class when the event is received.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org
[jira] Commented: (TAPESTRY-2146) Duplicated calls with base class
lifecycle methods
Posted by "angerclown (JIRA)" <de...@tapestry.apache.org>.
[ https://issues.apache.org/jira/browse/TAPESTRY-2146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12567444#action_12567444 ]
angerclown commented on TAPESTRY-2146:
--------------------------------------
Thinking about the issue more, I realized the real solution is to just drop the lifecycle call in the generated page class. The generated code for page Test should be something like
public void containingPageDidDetach()
{
super.containingPageDidDetach();
Object obj = null;
// no need to call pageDetached here since
// super.containingPageDidDetach will call it
//pageDetached();
}
This result in the following call stack, which is what we want.
TestBase.pageDetached()
Test.pageDetached()
TestBase.containingPageDidDetach()
Test.containingPageDidDetach()
> Duplicated calls with base class lifecycle methods
> --------------------------------------------------
>
> Key: TAPESTRY-2146
> URL: https://issues.apache.org/jira/browse/TAPESTRY-2146
> Project: Tapestry
> Issue Type: Bug
> Components: Core Components
> Affects Versions: 5.0.9
> Reporter: angerclown
>
> When using a base class with a component, any lifecycle method (pageDetached, pageLoaded, activate, etc) call is duplicated. The core issue seems to be that both the base class and the page class are enhanced to make calls to lifecycle methods and the page class is then calling super.
> For example:
> package test.base;
> public class TestBase {
> public void pageDetached() {
> System.out.println("Base Detached");
> }
> }
> package test.pages;
> public class Test extends TestBase {
> @Override
> public void pageDetached() {
> super.pageDetached();
> System.out.println("Detached");
> }
> }
> The output will be:
> Base Detached
> Detached
> Base Detached
> Detached
> Removing the super.pageDetached() call just outputs Detached twice.
> Looking at the source for the both classes (after writing to disk and decompiling with jad):
> Base Class
> public void containingPageDidDetach()
> {
> Object obj = null;
> pageDetached();
> }
> Page Class
> public void containingPageDidDetach()
> {
> super.containingPageDidDetach();
> Object obj = null;
> pageDetached();
> }
> This is not right since the event is called once for each page. Either 1) the base class should not have these methods enhanced at all or 2) the enchanced page method should not call super. Option 1 seems a little more natural since that would imply you must make super calls in the non-enhanced page classes, i.e. the code you write and expect to call super in anyway. With option 2, there would be more "magic" -- you don't call super in your page detached method, but super.pageDetached gets called anyway by the enhanced class when the event is received.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org