Author: hlship
Date: Mon Sep 20 20:22:44 2010
New Revision: 999102

URL: http://svn.apache.org/viewvc?rev=999102&view=rev
Log:
Merge branch 'TAP5-1011' into trunk

Added:
    tapestry/tapestry5/trunk/tapestry-core/src/test/app1/PACAnnotationDemo.tml
    
tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/PageActivationContextAnnotationTests.groovy
    
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/PACAnnotationDemo.java
   (with props)
Modified:
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/InternalClassTransformationImpl.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/PageActivationContextWorker.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/ClassTransformation.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
    
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/InternalClassTransformationImpl.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/InternalClassTransformationImpl.java?rev=999102&r1=999101&r2=999102&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/InternalClassTransformationImpl.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/InternalClassTransformationImpl.java
 Mon Sep 20 20:22:44 2010
@@ -2371,19 +2371,22 @@ public final class InternalClassTransfor
         {
             public void advise(ComponentMethodInvocation invocation)
             {
+                // Invoke the super-class implementation first.
+                
+                invocation.proceed();
+                
                 ComponentEvent event = (ComponentEvent) 
invocation.getParameter(0);
 
-                if (event.matches(eventType, "", minContextValues))
+                if (!event.isAborted() && event.matches(eventType, "", 
minContextValues))
                 {
                     event.setMethodDescription(methodDescription);
 
                     handler.handleEvent(invocation.getInstance(), event);
 
+                    // Ensure that the caller knows that some event handler 
method
+                    // was invoked.
                     invocation.overrideResult(true);
                 }
-
-                if (!event.isAborted())
-                    invocation.proceed();
             }
         };
     }

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/PageActivationContextWorker.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/PageActivationContextWorker.java?rev=999102&r1=999101&r2=999102&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/PageActivationContextWorker.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/PageActivationContextWorker.java
 Mon Sep 20 20:22:44 2010
@@ -24,12 +24,8 @@ import org.apache.tapestry5.runtime.Comp
 import org.apache.tapestry5.services.ClassTransformation;
 import org.apache.tapestry5.services.ComponentClassTransformWorker;
 import org.apache.tapestry5.services.ComponentEventHandler;
-import org.apache.tapestry5.services.ComponentMethodAdvice;
-import org.apache.tapestry5.services.ComponentMethodInvocation;
 import org.apache.tapestry5.services.FieldAccess;
-import org.apache.tapestry5.services.TransformConstants;
 import org.apache.tapestry5.services.TransformField;
-import org.apache.tapestry5.services.TransformMethod;
 
 /**
  * Provides the page activation context handlers. This worker must be 
scheduled before

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/ClassTransformation.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/ClassTransformation.java?rev=999102&r1=999101&r2=999102&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/ClassTransformation.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/ClassTransformation.java
 Mon Sep 20 20:22:44 2010
@@ -623,9 +623,10 @@ public interface ClassTransformation ext
     /**
      * Adds advice to the {...@link 
Component#dispatchComponentEvent(org.apache.tapestry5.runtime.ComponentEvent)} 
method.
      * If the handler is invoked,
-     * the return value of the method will be overriden to true. The 
invocation will proceeed either way (whether the
-     * handler is invoked or not). Updates {...@linkplain 
MutableComponentModel#addEventHandler(String) the model} to
-     * indicate that there is a handler for the named event.
+     * the return value of the method will be overriden to true. Updates
+     * {...@linkplain MutableComponentModel#addEventHandler(String) the model} 
to
+     * indicate that there is a handler for the named event. Existing 
handlers, or super-class handlers,
+     * are invoked <em>first</em>.
      * 
      * @param eventType
      *            name of event to be handled

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java?rev=999102&r1=999101&r2=999102&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
 Mon Sep 20 20:22:44 2010
@@ -611,7 +611,7 @@ public final class TapestryModule
         configuration.add("Component", new ComponentWorker(resolver));
         configuration.add("Mixin", new MixinWorker(resolver));
         configuration.addInstance("ActivationRequestParameter", 
ActivationRequestParameterWorker.class,
-                "before:OnEvent");
+                "after:OnEvent");
         configuration.addInstance("OnEvent", OnEventWorker.class);
         configuration.add("SupportsInformalParameters", new 
SupportsInformalParametersWorker());
         configuration.addInstance("InjectPage", InjectPageWorker.class);
@@ -671,7 +671,7 @@ public final class TapestryModule
 
         configuration.addInstance("UnclaimedField", 
UnclaimedFieldWorker.class, "after:*");
 
-        configuration.add("PageActivationContext", new 
PageActivationContextWorker(), "before:OnEvent");
+        configuration.add("PageActivationContext", new 
PageActivationContextWorker(), "after:OnEvent");
 
         configuration.addInstance("SessionAttribute", 
SessionAttributeWorker.class);
 

Added: 
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/PACAnnotationDemo.tml
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/PACAnnotationDemo.tml?rev=999102&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/PACAnnotationDemo.tml 
(added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/PACAnnotationDemo.tml 
Mon Sep 20 20:22:44 2010
@@ -0,0 +1,16 @@
+<html t:type="Border" 
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";>
+
+  <h1>@PageActivationContext Demo</h1>
+
+  <dl>
+    <dt>count</dt>
+    <dd id="count">${count}</dd>
+
+    <dt>count set</dt>
+    <dd id="count-set">${countSet}</dd>
+  </dl>
+
+  <p>
+    <t:pagelink page="pacannotationdemo" context="99">activate page with 
context</t:pagelink>
+  </p>
+</html>
\ No newline at end of file

Added: 
tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/PageActivationContextAnnotationTests.groovy
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/PageActivationContextAnnotationTests.groovy?rev=999102&view=auto
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/PageActivationContextAnnotationTests.groovy
 (added)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/PageActivationContextAnnotationTests.groovy
 Mon Sep 20 20:22:44 2010
@@ -0,0 +1,35 @@
+// Copyright 2010 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry5.integration.app1
+
+import org.apache.tapestry5.integration.TapestryCoreTestCase;
+import org.testng.annotations.Test 
+
+class PageActivationContextAnnotationTests extends TapestryCoreTestCase
+{
+    @Test
+    void pac_fields_set_before_activate_event_handler_method_invoked()
+    {
+        clickThru "PageActivationContext Demo"
+        
+        assertText "count", ""
+        assertText "count-set", "false"
+        
+        clickAndWait "link=activate page with context"
+        
+        assertText "count", "99"
+        assertText "count-set", "true"
+    }
+}

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java?rev=999102&r1=999101&r2=999102&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
 Mon Sep 20 20:22:44 2010
@@ -72,6 +72,9 @@ public class Index
     private static final List<Item> ITEMS = CollectionFactory
             .newList(
 
+                    new Item("PACAnnotationDemo", "PageActivationContext Demo",
+                            "Shows that @PageActivationContext fields are set 
before calls to the activate event handler."),
+
                     new Item("PublicFieldAccessDemo", "Public Field Access 
Demo", "Demonstrates TAP5-1222 fix"),
 
                     new Item("ActivationRequestParameterDemo", 
"ActivationRequestParameter Annotation Demo",
@@ -451,10 +454,12 @@ public class Index
 
                     new Item("SelectModelFromObjectsAndPropertyNameDemo", 
"SelectModel from objects and property name",
                             "Creating a SelectModel from a list of objects and 
a label property name"),
-                            
-                    new Item("DecoratePageRenderLinkDemo", "Decorate Page 
Render Link Demo", "Decorating page render links"),
-                    
-                    new Item("DecorateComponentEventLinkDemo", "Decorate 
Component Event Link Demo", "Decorating event links")
+
+                    new Item("DecoratePageRenderLinkDemo", "Decorate Page 
Render Link Demo",
+                            "Decorating page render links"),
+
+                    new Item("DecorateComponentEventLinkDemo", "Decorate 
Component Event Link Demo",
+                            "Decorating event links")
 
             );
 

Added: 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/PACAnnotationDemo.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/PACAnnotationDemo.java?rev=999102&view=auto
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/PACAnnotationDemo.java
 (added)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/PACAnnotationDemo.java
 Mon Sep 20 20:22:44 2010
@@ -0,0 +1,33 @@
+// Copyright 2010 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry5.integration.app1.pages;
+
+import org.apache.tapestry5.annotations.PageActivationContext;
+import org.apache.tapestry5.annotations.Property;
+
+public class PACAnnotationDemo
+{
+    @Property
+    @PageActivationContext
+    private Integer count;
+
+    @Property
+    private boolean countSet;
+
+    void onActivate()
+    {
+        countSet = count != null;
+    }
+}

Propchange: 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/PACAnnotationDemo.java
------------------------------------------------------------------------------
    svn:eol-style = native


Reply via email to