You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2008/10/16 22:30:21 UTC
svn commit: r705353 - in /tapestry/tapestry5/trunk/tapestry-core/src:
main/java/org/apache/tapestry5/internal/services/
main/resources/org/apache/tapestry5/internal/services/ test/app1/
test/app4/ test/java/org/apache/tapestry5/integration/ test/java/o...
Author: hlship
Date: Thu Oct 16 13:30:21 2008
New Revision: 705353
URL: http://svn.apache.org/viewvc?rev=705353&view=rev
Log:
TAP5-285: Components such as ActionLink and EventLink should require that there be *some* event handler for their triggered events
Added:
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/UnhandledEventDemo.tml
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/UnhandledEventDemo.java
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AjaxComponentEventRequestHandler.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentEventRequestHandlerImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ServicesMessages.java
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/services/ServicesStrings.properties
tapestry/tapestry5/trunk/tapestry-core/src/test/app4/Destination.tml
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Start.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app4/pages/Destination.java
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AjaxComponentEventRequestHandler.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AjaxComponentEventRequestHandler.java?rev=705353&r1=705352&r2=705353&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AjaxComponentEventRequestHandler.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AjaxComponentEventRequestHandler.java Thu Oct 16 13:30:21 2008
@@ -20,6 +20,7 @@
import org.apache.tapestry5.internal.structure.ComponentPageElement;
import org.apache.tapestry5.internal.structure.Page;
import org.apache.tapestry5.internal.util.Holder;
+import org.apache.tapestry5.ioc.internal.util.TapestryException;
import org.apache.tapestry5.json.JSONObject;
import org.apache.tapestry5.services.*;
@@ -103,7 +104,12 @@
environment.push(ComponentEventResultProcessor.class, interceptor);
- element.triggerContextEvent(parameters.getEventType(), parameters.getEventContext(), callback);
+ boolean handled = element.triggerContextEvent(parameters.getEventType(), parameters.getEventContext(),
+ callback);
+
+ if (!handled)
+ throw new TapestryException(ServicesMessages.eventNotHandled(element, parameters.getEventType()), element,
+ null);
environment.pop(ComponentEventResultProcessor.class);
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentEventRequestHandlerImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentEventRequestHandlerImpl.java?rev=705353&r1=705352&r2=705353&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentEventRequestHandlerImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentEventRequestHandlerImpl.java Thu Oct 16 13:30:21 2008
@@ -17,6 +17,7 @@
import org.apache.tapestry5.EventConstants;
import org.apache.tapestry5.internal.structure.ComponentPageElement;
import org.apache.tapestry5.internal.structure.Page;
+import org.apache.tapestry5.ioc.internal.util.TapestryException;
import org.apache.tapestry5.services.*;
import java.io.IOException;
@@ -64,7 +65,12 @@
environment.push(ComponentEventResultProcessor.class, resultProcessor);
- element.triggerContextEvent(parameters.getEventType(), parameters.getEventContext(), callback);
+ boolean handled = element.triggerContextEvent(parameters.getEventType(), parameters.getEventContext(),
+ callback);
+
+ if (!handled)
+ throw new TapestryException(ServicesMessages.eventNotHandled(element, parameters.getEventType()), element,
+ null);
environment.pop(ComponentEventResultProcessor.class);
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ServicesMessages.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ServicesMessages.java?rev=705353&r1=705352&r2=705353&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ServicesMessages.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ServicesMessages.java Thu Oct 16 13:30:21 2008
@@ -15,6 +15,7 @@
package org.apache.tapestry5.internal.services;
import javassist.CtClass;
+import org.apache.tapestry5.internal.structure.ComponentPageElement;
import org.apache.tapestry5.ioc.Location;
import org.apache.tapestry5.ioc.Messages;
import org.apache.tapestry5.ioc.Resource;
@@ -260,7 +261,6 @@
return MESSAGES.format("missing-from-environment", type.getName(), InternalUtils
.joinSorted(types));
-
}
static String invalidComponentEventResult(Object result,
@@ -414,4 +414,9 @@
{
return MESSAGES.format("forbid-instantiate-component-class", className);
}
+
+ static String eventNotHandled(ComponentPageElement element, String eventName)
+ {
+ return MESSAGES.format("event-not-handled", eventName, element.getCompleteId());
+ }
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/services/ServicesStrings.properties
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/services/ServicesStrings.properties?rev=705353&r1=705352&r2=705353&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/services/ServicesStrings.properties (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/services/ServicesStrings.properties Thu Oct 16 13:30:21 2008
@@ -92,4 +92,5 @@
parameter-binding-must-not-be-empty=Parameter '%s' must have a non-empty binding.
no-such-method=Class %s does not contain a method named '%s()'.
context-value-may-not-be-null=Context values (which are added to the request URL) may not be null or blank.
-forbid-instantiate-component-class=Component class %s may not be instantiated directly. You should use an @InjectPage or @InjectComponent annotation instead.
\ No newline at end of file
+forbid-instantiate-component-class=Component class %s may not be instantiated directly. You should use an @InjectPage or @InjectComponent annotation instead.
+event-not-handled=Request event '%s' (on component %s) was not handled; you must provide a matching event handler method in the component or in one of its containers.
\ No newline at end of file
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/UnhandledEventDemo.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/UnhandledEventDemo.tml?rev=705353&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/UnhandledEventDemo.tml (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/UnhandledEventDemo.tml Thu Oct 16 13:30:21 2008
@@ -0,0 +1,17 @@
+<html t:type="Border" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+
+ <h1>Unhandled Event Demo</h1>
+
+ <t:zone id="update">
+
+ </t:zone>
+
+ <ul>
+ <li id="traditional">
+ <t:actionlink t:id="traditional">traditional</t:actionlink>
+ </li>
+ <li>
+ <t:actionlink t:id="ajax" zone="update">ajax</t:actionlink>
+ </li>
+ </ul>
+</html>
\ No newline at end of file
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/app4/Destination.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app4/Destination.tml?rev=705353&r1=705352&r2=705353&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app4/Destination.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app4/Destination.tml Thu Oct 16 13:30:21 2008
@@ -20,7 +20,7 @@
<hr/>
- <t:actionlink>refresh via action</t:actionlink>
+ <t:actionlink t:id="refresh">refresh via action</t:actionlink>
</body>
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java?rev=705353&r1=705352&r2=705353&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java Thu Oct 16 13:30:21 2008
@@ -2327,4 +2327,25 @@
assertText("value", "99");
}
+
+ /**
+ * TAP5-285
+ */
+ public void unhandled_client_events_throw_exceptions()
+ {
+ start("Unhandled Event Demo");
+
+ click("link=ajax");
+
+ waitForCondition("selenium.browserbot.getCurrentWindow().$$('DIV.t-ajax-console DIV.t-err').first()",
+ PAGE_LOAD_TIMEOUT);
+
+ assertText("//DIV[@class='t-ajax-console']/DIV[@class='t-err']",
+ "Communication with the server failed: Request event 'action' (on component UnhandledEventDemo:ajax) was not handled; you must provide a matching event handler method in the component or in one of its containers.");
+
+ start("Unhandled Event Demo", "traditional");
+
+ assertTextPresent(
+ "Request event 'action' (on component UnhandledEventDemo:traditional) was not handled; you must provide a matching event handler method in the component or in one of its containers.");
+ }
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Start.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Start.java?rev=705353&r1=705352&r2=705353&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Start.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Start.java Thu Oct 16 13:30:21 2008
@@ -65,6 +65,9 @@
private static final List<Item> ITEMS = CollectionFactory.newList(
+ new Item("UnhandledEventDemo", "Unhandled Event Demo",
+ "Events that don't have matching event handlers cause exceptions"),
+
new Item("PrimitiveDefaultDemo", "Primitive Default Demo",
"Primitive value returned from parameter default method"),
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/UnhandledEventDemo.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/UnhandledEventDemo.java?rev=705353&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/UnhandledEventDemo.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/UnhandledEventDemo.java Thu Oct 16 13:30:21 2008
@@ -0,0 +1,19 @@
+// Copyright 2008 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;
+
+public class UnhandledEventDemo
+{
+}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app4/pages/Destination.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app4/pages/Destination.java?rev=705353&r1=705352&r2=705353&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app4/pages/Destination.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app4/pages/Destination.java Thu Oct 16 13:30:21 2008
@@ -63,5 +63,5 @@
message += " - " + text;
}
-
+ void onActionFromRefresh() { }
}