You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2008/01/23 17:44:58 UTC

svn commit: r614581 [2/3] - in /tapestry/tapestry5/trunk: tapestry-core/src/main/java/org/apache/tapestry/internal/ tapestry-core/src/main/java/org/apache/tapestry/internal/bindings/ tapestry-core/src/main/java/org/apache/tapestry/internal/services/ ta...

Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/PageResourcesImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/PageResourcesImpl.java?rev=614581&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/PageResourcesImpl.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/PageResourcesImpl.java Wed Jan 23 08:44:46 2008
@@ -0,0 +1,58 @@
+// 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.tapestry.internal.structure;
+
+import org.apache.tapestry.internal.services.ComponentClassCache;
+import org.apache.tapestry.ioc.Messages;
+import org.apache.tapestry.ioc.services.TypeCoercer;
+import org.apache.tapestry.model.ComponentModel;
+import org.apache.tapestry.services.ComponentMessagesSource;
+
+import java.util.Locale;
+
+public class PageResourcesImpl implements PageResources
+{
+    private final Locale _locale;
+
+    private final ComponentMessagesSource _componentMessagesSource;
+
+    private final TypeCoercer _typeCoercer;
+
+    private final ComponentClassCache _componentClassCache;
+
+    public PageResourcesImpl(Locale locale, ComponentMessagesSource componentMessagesSource, TypeCoercer typeCoercer,
+                             ComponentClassCache componentClassCache)
+    {
+        _componentMessagesSource = componentMessagesSource;
+        _locale = locale;
+        _typeCoercer = typeCoercer;
+        _componentClassCache = componentClassCache;
+    }
+
+    public Messages getMessages(ComponentModel componentModel)
+    {
+        return _componentMessagesSource.getMessages(componentModel, _locale);
+    }
+
+    public <S, T> T coerce(S input, Class<T> targetType)
+    {
+        return _typeCoercer.coerce(input, targetType);
+    }
+
+    public Class toClass(String className)
+    {
+        return _componentClassCache.forName(className);
+    }
+}

Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/PageResourcesSource.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/PageResourcesSource.java?rev=614581&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/PageResourcesSource.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/PageResourcesSource.java Wed Jan 23 08:44:46 2008
@@ -0,0 +1,31 @@
+// 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.tapestry.internal.structure;
+
+import java.util.Locale;
+
+/**
+ * Provides access to the {@link PageResources} facade.
+ */
+public interface PageResourcesSource
+{
+    /**
+     * Gets (or creates) an instance of {@link PageResources} for the indicated locale.
+     *
+     * @param locale to create the resources for
+     * @return the resources
+     */
+    PageResources get(Locale locale);
+}

Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/PageResourcesSourceImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/PageResourcesSourceImpl.java?rev=614581&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/PageResourcesSourceImpl.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/PageResourcesSourceImpl.java Wed Jan 23 08:44:46 2008
@@ -0,0 +1,62 @@
+// 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.tapestry.internal.structure;
+
+import org.apache.tapestry.internal.services.ComponentClassCache;
+import org.apache.tapestry.ioc.internal.util.CollectionFactory;
+import org.apache.tapestry.ioc.internal.util.Defense;
+import org.apache.tapestry.ioc.services.TypeCoercer;
+import org.apache.tapestry.services.ComponentMessagesSource;
+
+import java.util.Locale;
+import java.util.Map;
+
+public class PageResourcesSourceImpl implements PageResourcesSource
+{
+    private final Map<Locale, PageResources> _cache = CollectionFactory.newConcurrentMap();
+
+    private final ComponentMessagesSource _componentMessagesSource;
+
+    private final TypeCoercer _typeCoercer;
+
+    private final ComponentClassCache _componentClassCache;
+
+    public PageResourcesSourceImpl(ComponentMessagesSource componentMessagesSource, TypeCoercer typeCoercer,
+                                   ComponentClassCache componentClassCache)
+    {
+        _componentMessagesSource = componentMessagesSource;
+        _typeCoercer = typeCoercer;
+        _componentClassCache = componentClassCache;
+    }
+
+    public PageResources get(Locale locale)
+    {
+        Defense.notNull(locale, "locale");
+
+        PageResources result = _cache.get(locale);
+
+        if (result == null)
+        {
+            result = new PageResourcesImpl(locale, _componentMessagesSource, _typeCoercer, _componentClassCache);
+
+            // Small race condition here, where we may create two instances of PRI for the same locale,
+            // but that's not worth worrying about.
+
+            _cache.put(locale, result);
+        }
+
+        return result;
+    }
+}

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/ActionLinkInvoker.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/ActionLinkInvoker.java?rev=614581&r1=614580&r2=614581&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/ActionLinkInvoker.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/ActionLinkInvoker.java Wed Jan 23 08:44:46 2008
@@ -22,8 +22,8 @@
 import org.apache.tapestry.internal.services.InvocationTarget;
 import org.apache.tapestry.ioc.Registry;
 import org.apache.tapestry.ioc.internal.util.Defense;
-import org.apache.tapestry.services.ComponentActionRequestHandler;
-import org.apache.tapestry.services.ComponentActionRequestParameters;
+import org.apache.tapestry.services.ComponentEventRequestHandler;
+import org.apache.tapestry.services.ComponentEventRequestParameters;
 
 import java.io.IOException;
 
@@ -36,7 +36,7 @@
 
     private final ComponentInvoker _followupInvoker;
 
-    private final ComponentActionRequestHandler _componentActionRequestHandler;
+    private final ComponentEventRequestHandler _componentEventRequestHandler;
 
     private final ComponentInvocationMap _componentInvocationMap;
 
@@ -47,8 +47,8 @@
     {
         _registry = registry;
         _followupInvoker = followupInvoker;
-        _componentActionRequestHandler = _registry.getService("ComponentActionRequestHandler",
-                                                              ComponentActionRequestHandler.class);
+        _componentEventRequestHandler = _registry.getService("ComponentActionRequestHandler",
+                                                             ComponentEventRequestHandler.class);
 
         _response = _registry.getObject(TestableResponse.class, null);
 
@@ -87,7 +87,7 @@
 
             ActionLinkTarget actionLinkTarget = Defense.cast(target, ActionLinkTarget.class, "target");
 
-            ComponentActionRequestParameters parameters = new ComponentActionRequestParameters(
+            ComponentEventRequestParameters parameters = new ComponentEventRequestParameters(
                     actionLinkTarget.getPageName(),
 
                     actionLinkTarget.getPageName(),
@@ -100,7 +100,7 @@
 
                     invocation.getContext());
 
-            _componentActionRequestHandler.handle(parameters);
+            _componentEventRequestHandler.handle(parameters);
         }
         catch (IOException e)
         {

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/runtime/Component.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/runtime/Component.java?rev=614581&r1=614580&r2=614581&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/runtime/Component.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/runtime/Component.java Wed Jan 23 08:44:46 2008
@@ -18,13 +18,13 @@
 import org.apache.tapestry.annotations.OnEvent;
 
 /**
- * Interface that defines the lifecycle of a component, within a page, allowing for callbacks into
- * the component for many different events. This interface is part of the public API for Tapestry,
- * but is <em>not</em> expected to be directly implemented by component classes; it should only be
- * implemented as part of the component class transformation process.
+ * Interface that defines the lifecycle of a component, within a page, allowing for callbacks into the component for
+ * many different events. This interface is part of the public API for Tapestry, but is <em>not</em> expected to be
+ * directly implemented by component classes; it should only be implemented as part of the component class
+ * transformation process.
  * <p/>
- * Most of the methods are related to render phases; see the corresponding annotations and component
- * rendering documentation to see how they relate to each other.
+ * Most of the methods are related to render phases; see the corresponding annotations and component rendering
+ * documentation to see how they relate to each other.
  * <p/>
  * This interface is likely to change without notice.
  */
@@ -32,10 +32,9 @@
 {
 
     /**
-     * Lifecycle method invoked at the end of the
-     * {@link org.apache.tapestry.annotations.CleanupRender} render phase. There is no annotation
-     * for this method, it is part of CleanupRender, but is always invoked. Its specific use is to
-     * allow components to clean up cached parameter values.
+     * Lifecycle method invoked at the end of the {@link org.apache.tapestry.annotations.CleanupRender} render phase.
+     * There is no annotation for this method, it is part of CleanupRender, but is always invoked. Its specific use is
+     * to allow components to clean up cached parameter values.
      */
     void postRenderCleanup();
 
@@ -70,8 +69,8 @@
     void afterRenderBody(MarkupWriter writer, Event event);
 
     /**
-     * Generally used to write the close tag matching any open tag written by
-     * {@link #beginRender(org.apache.tapestry.MarkupWriter, Event)}.
+     * Generally used to write the close tag matching any open tag written by {@link
+     * #beginRender(org.apache.tapestry.MarkupWriter, Event)}.
      */
     void afterRender(MarkupWriter writer, Event event);
 
@@ -81,12 +80,12 @@
     void cleanupRender(MarkupWriter writer, Event event);
 
     /**
-     * Invoked to handle a component event. Methods with the {@link OnEvent} annotation (or the matching
-     * naming convention) will be invoked until one returns a non-null value.
+     * Invoked to handle a component event. Methods with the {@link OnEvent} annotation (or the matching naming
+     * convention) will be invoked until one returns a non-null value.
      *
      * @param event
      * @return true if any handler was found (and invoked), false otherwise
-     * @throws ComponentEventException if an event handler throws an exception
+     * @throws RuntimeException wrapping any checked exceptions that are thrown by individual event handler methods
      */
-    boolean handleComponentEvent(ComponentEvent event);
+    boolean dispatchComponentEvent(ComponentEvent event);
 }

Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/runtime/ComponentEventException.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/runtime/ComponentEventException.java?rev=614581&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/runtime/ComponentEventException.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/runtime/ComponentEventException.java Wed Jan 23 08:44:46 2008
@@ -0,0 +1,54 @@
+// 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.tapestry.runtime;
+
+import org.apache.tapestry.ioc.internal.util.TapestryException;
+
+/**
+ * A wrapper exception around any exception thrown when invoking a component event handler. In some cases, the
+ * underlying exception may have been a declared exception, and will be wrapped in a RuntimeException.
+ *
+ * @see org.apache.tapestry.ioc.util.ExceptionUtils#findCause(Throwable, Class)
+ */
+public class ComponentEventException extends TapestryException
+{
+    private final String _eventType;
+    private final Object[] _context;
+
+    /**
+     * @param message   exception message
+     * @param eventType type of event that triggered the exception
+     * @param context   context passed with the failed event
+     * @param location  location of the component while failed (may be null)
+     * @param cause     underlying exception
+     */
+    public ComponentEventException(String message, String eventType, Object[] context, Object location, Throwable cause)
+    {
+        super(message, location, cause);
+
+        _eventType = eventType;
+        _context = context;
+    }
+
+    public String getEventType()
+    {
+        return _eventType;
+    }
+
+    public Object[] getContext()
+    {
+        return _context;
+    }
+}

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/Ajax.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/Ajax.java?rev=614581&r1=614580&r2=614581&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/Ajax.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/Ajax.java Wed Jan 23 08:44:46 2008
@@ -1,4 +1,4 @@
-// Copyright 2007 The Apache Software Foundation
+// Copyright 2007, 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.
@@ -18,10 +18,10 @@
 
 
 /**
- * Marker annotation for services related to processing an Ajax request (rather than
- * a {@linkplain org.apache.tapestry.services.Traditional traditional request}).
+ * Marker annotation for services related to processing an Ajax request (rather than a {@linkplain
+ * org.apache.tapestry.services.Traditional traditional request}).
  *
- * @see org.apache.tapestry.services.ComponentActionRequestHandler
+ * @see ComponentEventRequestHandler
  */
 @Target({ElementType.PARAMETER, ElementType.FIELD})
 @Retention(RetentionPolicy.RUNTIME)

Copied: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/ComponentEventRequestFilter.java (from r612337, tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/ComponentActionRequestFilter.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/ComponentEventRequestFilter.java?p2=tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/ComponentEventRequestFilter.java&p1=tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/ComponentActionRequestFilter.java&r1=612337&r2=614581&rev=614581&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/ComponentActionRequestFilter.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/ComponentEventRequestFilter.java Wed Jan 23 08:44:46 2008
@@ -17,13 +17,13 @@
 import java.io.IOException;
 
 /**
- * Filter interface for {@link ComponentActionRequestHandler}.
+ * Filter interface for {@link ComponentEventRequestHandler}.
  *
  * @see org.apache.tapestry.services.TapestryModule#contributeComponentActionRequestHandler(org.apache.tapestry.ioc.OrderedConfiguration,
- *      org.apache.tapestry.internal.services.RequestEncodingInitializer, ComponentActionRequestHandler,
+ *      org.apache.tapestry.internal.services.RequestEncodingInitializer, ComponentEventRequestHandler ,
  *      org.apache.tapestry.ioc.ObjectLocator) }
  */
-public interface ComponentActionRequestFilter
+public interface ComponentEventRequestFilter
 {
     /**
      * Filter for a component action request.
@@ -31,5 +31,5 @@
      * @param parameters defining details of the request
      * @param handler    to delegate to
      */
-    void handle(ComponentActionRequestParameters parameters, ComponentActionRequestHandler handler) throws IOException;
+    void handle(ComponentEventRequestParameters parameters, ComponentEventRequestHandler handler) throws IOException;
 }

Copied: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/ComponentEventRequestHandler.java (from r612337, tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/ComponentActionRequestHandler.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/ComponentEventRequestHandler.java?p2=tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/ComponentEventRequestHandler.java&p1=tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/ComponentActionRequestHandler.java&r1=612337&r2=614581&rev=614581&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/ComponentActionRequestHandler.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/ComponentEventRequestHandler.java Wed Jan 23 08:44:46 2008
@@ -26,9 +26,9 @@
  *
  * @see ActionLink
  * @see Form
- * @see ComponentActionRequestFilter
+ * @see ComponentEventRequestFilter
  */
-public interface ComponentActionRequestHandler
+public interface ComponentEventRequestHandler
 {
     /**
      * Handler for a component action request which will trigger an event on a component and use the return value to
@@ -36,5 +36,5 @@
      *
      * @param parameters defining the requst
      */
-    void handle(ComponentActionRequestParameters parameters) throws IOException;
+    void handle(ComponentEventRequestParameters parameters) throws IOException;
 }

Copied: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/ComponentEventRequestParameters.java (from r612337, tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/ComponentActionRequestParameters.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/ComponentEventRequestParameters.java?p2=tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/ComponentEventRequestParameters.java&p1=tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/ComponentActionRequestParameters.java&r1=612337&r2=614581&rev=614581&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/ComponentActionRequestParameters.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/ComponentEventRequestParameters.java Wed Jan 23 08:44:46 2008
@@ -19,9 +19,9 @@
 import java.util.Arrays;
 
 /**
- * Encapsulates all the information that may be provided in a component action request URL.
+ * Encapsulates all the information that may be provided in a component event request URL.
  */
-public final class ComponentActionRequestParameters
+public final class ComponentEventRequestParameters
 {
     private final String _activePageName;
     private final String _containingPageName;
@@ -30,8 +30,8 @@
     private final String[] _pageActivationContext;
     private final String[] _eventContext;
 
-    public ComponentActionRequestParameters(String activePageName, String containingPageName, String nestedComponentId,
-                                            String eventType, String[] pageActivationContext, String[] eventContext)
+    public ComponentEventRequestParameters(String activePageName, String containingPageName, String nestedComponentId,
+                                           String eventType, String[] pageActivationContext, String[] eventContext)
     {
         Defense.notBlank(activePageName, "activePageName");
         Defense.notBlank(containingPageName, "containingPageName");
@@ -55,7 +55,7 @@
         if (this == o) return true;
         if (o == null || getClass() != o.getClass()) return false;
 
-        ComponentActionRequestParameters that = (ComponentActionRequestParameters) o;
+        ComponentEventRequestParameters that = (ComponentEventRequestParameters) o;
 
         if (!_activePageName.equals(that._activePageName)) return false;
         if (!_containingPageName.equals(that._containingPageName)) return false;

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/Dispatcher.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/Dispatcher.java?rev=614581&r1=614580&r2=614581&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/Dispatcher.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/Dispatcher.java Wed Jan 23 08:44:46 2008
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007 The Apache Software Foundation
+// Copyright 2006, 2007, 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.
@@ -17,18 +17,20 @@
 import java.io.IOException;
 
 /**
- * A dispatcher is responsible for recognizing an incoming request. Dispatchers form an ordered
- * chain of command, with each dispatcher responsible for recognizing requests that it can process.
+ * A dispatcher is responsible for recognizing an incoming request. Dispatchers form an ordered chain of command, with
+ * each dispatcher responsible for recognizing requests that it can process.
  *
- * @see org.apache.tapestry.services.TapestryModule#contributeMasterDispatcher(org.apache.tapestry.ioc.OrderedConfiguration, ClasspathAssetAliasManager, org.apache.tapestry.internal.services.ResourceCache, org.apache.tapestry.internal.services.ResourceStreamer, PageRenderRequestHandler, ComponentActionRequestHandler, ComponentClassResolver, String)
+ * @see org.apache.tapestry.services.TapestryModule#contributeMasterDispatcher(org.apache.tapestry.ioc.OrderedConfiguration,
+ *      ClasspathAssetAliasManager, org.apache.tapestry.internal.services.ResourceCache,
+ *      org.apache.tapestry.internal.services.ResourceStreamer, PageRenderRequestHandler, ComponentEventRequestHandler ,
+ *      ComponentClassResolver, String)
  */
 public interface Dispatcher
 {
     /**
      * Analyzes the incoming request and performs an appropriate operation for each.
      *
-     * @return true if a response was delivered, false if the servlet container should be allowed to
-     *         handle the request
+     * @return true if a response was delivered, false if the servlet container should be allowed to handle the request
      */
     boolean dispatch(Request request, Response response) throws IOException;
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java?rev=614581&r1=614580&r2=614581&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java Wed Jan 23 08:44:46 2008
@@ -27,6 +27,8 @@
 import org.apache.tapestry.internal.grid.CollectionGridDataSource;
 import org.apache.tapestry.internal.grid.NullDataSource;
 import org.apache.tapestry.internal.services.*;
+import org.apache.tapestry.internal.structure.PageResourcesSource;
+import org.apache.tapestry.internal.structure.PageResourcesSourceImpl;
 import org.apache.tapestry.internal.translator.*;
 import org.apache.tapestry.internal.util.IntegerRange;
 import org.apache.tapestry.ioc.*;
@@ -112,6 +114,7 @@
         binder.bind(RequestPathOptimizer.class, RequestPathOptimizerImpl.class);
         binder.bind(NullFieldStrategySource.class, NullFieldStrategySourceImpl.class);
         binder.bind(RequestFilter.class, IgnoredPathsFilter.class).withId("IgnoredPathsFilter");
+        binder.bind(PageResourcesSource.class, PageResourcesSourceImpl.class);
     }
 
     public static Alias build(Logger logger,
@@ -1171,6 +1174,14 @@
         configuration.add(StreamResponse.class, new StreamResponseResultProcessor(_response));
     }
 
+    /**
+     * The MasterDispatcher is a chain-of-command of individual Dispatchers, each handling (like a servlet) a particular
+     * kind of incoming request. <dl> <dt>RootPath</dt> <dd>Renders the start page for the "/" request</dd>
+     * <dt>Asset</dt> <dd>Provides access to classpath assets</dd> <dt>PageRender</dt> <dd>Identifies the page name and
+     * activation context and forwards onto {@link PageRenderRequestHandler}</dd> <dt>ComponentEvent</dt> <dd>Identifies
+     * the {@link ComponentEventRequestParameters} and forwards onto the {@link ComponentEventRequestHandler}</dd>
+     * </dl>
+     */
     public void contributeMasterDispatcher(OrderedConfiguration<Dispatcher> configuration,
 
                                            ClasspathAssetAliasManager aliasManager,
@@ -1181,7 +1192,7 @@
 
                                            PageRenderRequestHandler pageRenderRequestHandler,
 
-                                           @Traditional ComponentActionRequestHandler componentActionRequestHandler,
+                                           @Traditional ComponentEventRequestHandler componentEventRequestHandler,
 
                                            ComponentClassResolver componentClassResolver,
 
@@ -1201,8 +1212,8 @@
 
         configuration.add("PageRender", new PageRenderDispatcher(componentClassResolver, pageRenderRequestHandler));
 
-        configuration.add("ComponentAction",
-                          new ComponentActionDispatcher(componentActionRequestHandler, componentClassResolver),
+        configuration.add("ComponentEvent",
+                          new ComponentEventDispatcher(componentEventRequestHandler, componentClassResolver),
                           "after:PageRender");
     }
 
@@ -1578,26 +1589,26 @@
      * Builds the component action request handler for traditional (non-Ajax) requests. These typically result in a
      * redirect to a Tapestry render URL.
      *
-     * @see org.apache.tapestry.internal.services.ComponentActionRequestHandlerImpl
+     * @see org.apache.tapestry.internal.services.ComponentEventRequestHandlerImpl
      */
     @Marker(Traditional.class)
-    public ComponentActionRequestHandler buildComponentActionRequestHandler(
-            List<ComponentActionRequestFilter> configuration, Logger logger, ServiceResources resources)
+    public ComponentEventRequestHandler buildComponentActionRequestHandler(
+            List<ComponentEventRequestFilter> configuration, Logger logger, ServiceResources resources)
     {
-        return _pipelineBuilder.build(logger, ComponentActionRequestHandler.class, ComponentActionRequestFilter.class,
-                                      configuration, resources.autobuild(ComponentActionRequestHandlerImpl.class));
+        return _pipelineBuilder.build(logger, ComponentEventRequestHandler.class, ComponentEventRequestFilter.class,
+                                      configuration, resources.autobuild(ComponentEventRequestHandlerImpl.class));
     }
 
     /**
-     * Builds the action request handler for Ajax requests, based on {@link org.apache.tapestry.internal.services.AjaxComponentActionRequestHandler}.
+     * Builds the action request handler for Ajax requests, based on {@link org.apache.tapestry.internal.services.AjaxComponentEventRequestHandler}.
      * Filters on the request handler are supported here as well.
      */
     @Marker(Ajax.class)
-    public ComponentActionRequestHandler buildAjaxComponentActionRequestHandler(
-            List<ComponentActionRequestFilter> configuration, Logger logger, ServiceResources resources)
+    public ComponentEventRequestHandler buildAjaxComponentActionRequestHandler(
+            List<ComponentEventRequestFilter> configuration, Logger logger, ServiceResources resources)
     {
-        return _pipelineBuilder.build(logger, ComponentActionRequestHandler.class, ComponentActionRequestFilter.class,
-                                      configuration, resources.autobuild(AjaxComponentActionRequestHandler.class));
+        return _pipelineBuilder.build(logger, ComponentEventRequestHandler.class, ComponentEventRequestFilter.class,
+                                      configuration, resources.autobuild(AjaxComponentEventRequestHandler.class));
     }
 
     /**
@@ -2045,14 +2056,14 @@
      * immediate action response rendering} is enabled, generates the markup response (instead of a page redirect
      * response, which is the normal behavior) </dd> </dl>
      */
-    public void contributeComponentActionRequestHandler(
-            OrderedConfiguration<ComponentActionRequestFilter> configuration,
-            final RequestEncodingInitializer encodingInitializer, @Ajax ComponentActionRequestHandler ajaxHandler,
-            ObjectLocator locator)
+    public void contributeComponentActionRequestHandler(OrderedConfiguration<ComponentEventRequestFilter> configuration,
+                                                        final RequestEncodingInitializer encodingInitializer,
+                                                        @Ajax ComponentEventRequestHandler ajaxHandler,
+                                                        ObjectLocator locator)
     {
-        ComponentActionRequestFilter requestEncodingFilter = new ComponentActionRequestFilter()
+        ComponentEventRequestFilter requestEncodingFilter = new ComponentEventRequestFilter()
         {
-            public void handle(ComponentActionRequestParameters parameters, ComponentActionRequestHandler handler)
+            public void handle(ComponentEventRequestParameters parameters, ComponentEventRequestHandler handler)
                     throws IOException
             {
                 encodingInitializer.initializeRequestEncoding(parameters.getActivePageName());

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/Traditional.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/Traditional.java?rev=614581&r1=614580&r2=614581&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/Traditional.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/Traditional.java Wed Jan 23 08:44:46 2008
@@ -1,4 +1,4 @@
-// Copyright 2007 The Apache Software Foundation
+// Copyright 2007, 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.
@@ -18,10 +18,10 @@
 
 
 /**
- * Marker annotation for a service that should be used for traditional page oriented requests, as opposed to Ajax requests
- * (that send ad-hoc or {@linkplain PartialMarkupRenderer partial page markup} responses.
+ * Marker annotation for a service that should be used for traditional page oriented requests, as opposed to Ajax
+ * requests (that send ad-hoc or {@linkplain PartialMarkupRenderer partial page markup} responses.
  *
- * @see org.apache.tapestry.services.ComponentActionRequestHandler
+ * @see ComponentEventRequestHandler
  */
 @Target({ElementType.PARAMETER, ElementType.FIELD})
 @Retention(RetentionPolicy.RUNTIME)

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TransformConstants.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TransformConstants.java?rev=614581&r1=614580&r2=614581&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TransformConstants.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TransformConstants.java Wed Jan 23 08:44:46 2008
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007 The Apache Software Foundation
+// Copyright 2006, 2007, 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.
@@ -21,8 +21,7 @@
 import java.lang.reflect.Modifier;
 
 /**
- * Constants used by implementations of
- * {@link org.apache.tapestry.services.ComponentClassTransformWorker}.
+ * Constants used by implementations of {@link org.apache.tapestry.services.ComponentClassTransformWorker}.
  */
 public final class TransformConstants
 {
@@ -32,20 +31,15 @@
                                                                     Event.class.getName()};
 
     /**
-     * Signature for {@link org.apache.tapestry.runtime.Component#handleComponentEvent(org.apache.tapestry.runtime.ComponentEvent)}.
+     * Signature for {@link org.apache.tapestry.runtime.Component#dispatchComponentEvent(org.apache.tapestry.runtime.ComponentEvent)}.
      *
      * @see org.apache.tapestry.annotations.OnEvent
      */
-    public static final TransformMethodSignature HANDLE_COMPONENT_EVENT = new TransformMethodSignature(Modifier.PUBLIC,
-                                                                                                       "boolean",
-                                                                                                       "handleComponentEvent",
-                                                                                                       new String[]{
-                                                                                                               ComponentEvent.class.getName()},
-                                                                                                       null);
+    public static final TransformMethodSignature DISPATCH_COMPONENT_EVENT = new TransformMethodSignature(
+            Modifier.PUBLIC, "boolean", "dispatchComponentEvent", new String[]{ComponentEvent.class.getName()}, null);
 
     /**
-     * Signature for
-     * {@link org.apache.tapestry.runtime.PageLifecycleListener#containingPageDidLoad()}.
+     * Signature for {@link org.apache.tapestry.runtime.PageLifecycleListener#containingPageDidLoad()}.
      */
     public static final TransformMethodSignature CONTAINING_PAGE_DID_LOAD_SIGNATURE = new TransformMethodSignature(
             "containingPageDidLoad");
@@ -57,15 +51,13 @@
             "postRenderCleanup");
 
     /**
-     * Signature for
-     * {@link org.apache.tapestry.runtime.PageLifecycleListener#containingPageDidDetach()}.
+     * Signature for {@link org.apache.tapestry.runtime.PageLifecycleListener#containingPageDidDetach()}.
      */
     public static final TransformMethodSignature CONTAINING_PAGE_DID_DETACH_SIGNATURE = new TransformMethodSignature(
             "containingPageDidDetach");
 
     /**
-     * Signature for
-     * {@link org.apache.tapestry.runtime.PageLifecycleListener#containingPageDidAttach()}.
+     * Signature for {@link org.apache.tapestry.runtime.PageLifecycleListener#containingPageDidAttach()}.
      */
     public static final TransformMethodSignature CONTAINING_PAGE_DID_ATTACH_SIGNATURE = new TransformMethodSignature(
             "containingPageDidAttach");
@@ -85,8 +77,7 @@
     public static final TransformMethodSignature BEGIN_RENDER_SIGNATURE = renderPhaseSignature("beginRender");
 
     /**
-     * Signature for
-     * {@link org.apache.tapestry.runtime.Component#beforeRenderTemplate(MarkupWriter, Event)}.
+     * Signature for {@link org.apache.tapestry.runtime.Component#beforeRenderTemplate(MarkupWriter, Event)}.
      *
      * @see org.apache.tapestry.annotations.BeforeRenderTemplate
      */
@@ -94,8 +85,7 @@
             "beforeRenderTemplate");
 
     /**
-     * Signature for
-     * {@link org.apache.tapestry.runtime.Component#afterRenderTemplate(MarkupWriter, Event)}.
+     * Signature for {@link org.apache.tapestry.runtime.Component#afterRenderTemplate(MarkupWriter, Event)}.
      *
      * @see org.apache.tapestry.annotations.BeforeRenderTemplate
      */
@@ -103,8 +93,7 @@
             "afterRenderTemplate");
 
     /**
-     * Signature for
-     * {@link org.apache.tapestry.runtime.Component#beforeRenderBody(MarkupWriter, Event)}.
+     * Signature for {@link org.apache.tapestry.runtime.Component#beforeRenderBody(MarkupWriter, Event)}.
      *
      * @see org.apache.tapestry.annotations.BeforeRenderBody
      */
@@ -112,8 +101,7 @@
             "beforeRenderBody");
 
     /**
-     * Signature for
-     * {@link org.apache.tapestry.runtime.Component#afterRenderBody(MarkupWriter, Event)}.
+     * Signature for {@link org.apache.tapestry.runtime.Component#afterRenderBody(MarkupWriter, Event)}.
      *
      * @see org.apache.tapestry.annotations.AfterRenderBody
      */
@@ -127,8 +115,7 @@
     public static final TransformMethodSignature AFTER_RENDER_SIGNATURE = renderPhaseSignature("afterRender");
 
     /**
-     * Signature for
-     * {@link org.apache.tapestry.runtime.Component#cleanupRender(MarkupWriter, Event)}.
+     * Signature for {@link org.apache.tapestry.runtime.Component#cleanupRender(MarkupWriter, Event)}.
      *
      * @see org.apache.tapestry.annotations.CleanupRender
      */

Modified: tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/appstate.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/appstate.apt?rev=614581&r1=614580&r2=614581&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/appstate.apt (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/appstate.apt Wed Jan 23 08:44:46 2008
@@ -55,7 +55,17 @@
 
   This companion field is used to see if the ASO already exists. It is not annotated; it is located by name ("Exists" is appended to the name of the field
   storing the ASO). It must be type boolean and must be a private instance variable.  
-  
+
+  Alternately, you may allow for the state being null:
+
++---+
+  @ApplicationState(create=false)
+  private MyState _myState;
++---+
+
+  In this case, the _myState field will be null if the MyState ASO does not exist, but will be non-null if it has been
+  created (either by assigning a value to the field, or by a different ASO field where create is true).
+
 Persistence Strategies
 
   Each ASO is managed according to a persistence strategy. The default persistence strategy, "session", stores the ASOs inside the session.

Modified: tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/event.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/event.apt?rev=614581&r1=614580&r2=614581&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/event.apt (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/event.apt Wed Jan 23 08:44:46 2008
@@ -212,3 +212,38 @@
 
   Your event handler method may even declare that it "throws Exception" if that is more convienient.
 
+
+Intercepting Event Exceptions
+
+  When an event handler method throws an exception (checked or runtime), Tapestry gives the component and
+  its containing page a chance to handle the exception, before continuing on to
+  report the exception.
+
+  Tapestry fires a new event, of type "exception", passing the thrown exception as the context.  In fact,
+  the exception is wrapped inside a
+  {{{../../apidocs/org/apache/tapestry/runtime/ComponentEventException.html}ComponentEventException}}, from which
+  you may extract the event type and context.
+
+  Thus:
+
+---
+  Object onException(Throwable cause)
+  {
+    _message = cause.getMessage();
+
+    return this;
+  }
+---
+
+  The return value of the exception event handler <replaces> the return value of original event handler method.
+  For the typical case (an exception thrown by an "activate" or "action" event), this will be
+  a {{{pagenav.html}navigational response}} such as a page instance or page name.
+
+  This can be handy for handling cases where the data in the URL is misformatted.
+
+  In the above example, the navigational response is the page itself.
+
+  If there is no exception event handler, or the exception event handler returns null (or is void), then
+  then the exception will be passed to the
+  {{{../../apidocs/org/apache/tapestry/services/RequestExceptionHandler.html}RequestExceptionHandler}} service,
+  which (in default configuraton) will be render the exception page.
\ No newline at end of file

Modified: tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/parameters.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/parameters.apt?rev=614581&r1=614580&r2=614581&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/parameters.apt (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/parameters.apt Wed Jan 23 08:44:46 2008
@@ -374,7 +374,7 @@
   @Inject
   private ComponentResources _resources;
   
-  @Inject("alias:BindingSource")
+  @Inject
   private BindingSource _bindingSource;
   
   Binding defaultMessage()

Modified: tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/request.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/request.apt?rev=614581&r1=614580&r2=614581&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/request.apt (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/site/apt/guide/request.apt Wed Jan 23 08:44:46 2008
@@ -42,6 +42,9 @@
     {{{../../apidocs/org/apache/tapestry/services/RequestHandler.html}RequestHandler}} pipeline.
  
   []
+
+  Primarily, this exists to bridge from the Servlet API objects to the corresponding Tapestry objects.  This is the basis
+  for the planned portlet integration for Tapestry.
      
 RequestHandler Pipeline
  
@@ -50,7 +53,7 @@
    Tapestry require access to information in the request, such as query parameters, that information is obtained from the
    Request (or Response) objects.
    
-   The pipeline includes a number of built-in filters.  
+   The pipeline includes a number of built-in filters:  
    
    * CheckForUpdates is responsible for {{{reload.html}class and template reloading}}.
    
@@ -60,7 +63,7 @@
      the request, so that the servlet container can handle the reuest normally.
    
    * ErrorFilter catches uncaught exceptions from the lower levels of Tapestry and presents the exception report page.
-     This involves the {{{../../apidocs/org/apache/tapestry/services/RequestExceptionHandler.html}alias:RequestExceptionHandler}} service,
+     This involves the {{{../../apidocs/org/apache/tapestry/services/RequestExceptionHandler.html}RequestExceptionHandler}} service,
      which is responsible for initializing and rendering the
      {{{../../apidocs/org/apache/tapestry/corelib/pages/ExceptionReport.html}core/ExceptionReport}} page. 
     
@@ -101,9 +104,9 @@
   a page name "mypage". Assuming the second search was succesful, the page would be activated with the context "27".  If no logical page name
   can be identified, control passes to the next dispatcher.
 
-* ComponentAction
+* ComponentEvent
 
-  The component action dispatcher is used to trigger events in components.
+  The component event dispatcher is used to trigger events in components.
   
   The URL identifies the name of the page, then a series of component ids (the path from the page down to the specific component), then the name of the event to be
   triggered on the component. The remaining path elements are used as the context for the <event> (not for the page activation, which
@@ -133,7 +136,5 @@
   {{{http://tapestry.apache.org/tapestry5/tapestry-ioc/shadow.html}shadow}}
   of the RequestGlobals services' request property. That is, any methods invoked
   on this service are delegated to the request object stored inside the RequestGlobals.
-  
-  This service is also accessible with the object reference <<<alias:Request>>>.
    
   

Modified: tapestry/tapestry5/trunk/tapestry-core/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/site/apt/index.apt?rev=614581&r1=614580&r2=614581&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/site/apt/index.apt (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/site/apt/index.apt Wed Jan 23 08:44:46 2008
@@ -13,6 +13,10 @@
   Progress on Tapestry 5 is really taking off. This space lists some cool new features that have been added
   recently.
 
+  * Components can now supply an event handler for type "exception" which will be invoked when
+    an exception occurs in a component event handler method. This is useful for handling errors
+    with the context for the "activate" event.
+
   * Page instances are now cached more efficiently, with Tapestry attempting to control how many instances
     are created, and culling unused instances periodically.
 

Added: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/ExceptionEventDemo.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/ExceptionEventDemo.tml?rev=614581&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/ExceptionEventDemo.tml (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/ExceptionEventDemo.tml Wed Jan 23 08:44:46 2008
@@ -0,0 +1,28 @@
+<html t:type="Border" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+
+    <h1>Exception Event Demo</h1>
+
+    <t:if test="message">
+        <p id="message">
+            ${message}
+        </p>
+    </t:if>
+
+
+    <t:pagelink page="ExceptionEventDemo" context="invalidContext">force invalid activation context</t:pagelink>
+
+    <br/>
+
+    <t:actionlink t:id="fail" context="invalidContext">force invalid event context</t:actionlink>
+
+
+    <br/>
+
+    <p>
+        Exception interception: ${intercept} --
+        <t:actionlink t:id="enable">enable</t:actionlink>
+        /
+        <t:actionlink t:id="disable">disable</t:actionlink>
+    </p>
+
+</html>

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java?rev=614581&r1=614580&r2=614581&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java Wed Jan 23 08:44:46 2008
@@ -1198,7 +1198,12 @@
         type("count", "13");
         clickAndWait(SUBMIT);
 
-        assertTextPresent("Thirteen is an unlucky number.");
+        assertTextPresent("Event Handler Method Translate", "Thirteen is an unlucky number.");
+
+        type("count", "i");
+        clickAndWait(SUBMIT);
+
+        assertTextPresent("Event Handler Method Translate", "Rational numbers only, please.");
     }
 
     @Test
@@ -1446,5 +1451,32 @@
 
         assertSourcePresent(
                 "[Before label for Value]<label for=\"value\" id=\"value:label\">Value</label>[After label for Value][Before field Value]");
+    }
+
+    /**
+     * TAPESTRY-1724
+     */
+    @Test
+    public void component_event_errors()
+    {
+        start("Exception Event Demo", "enable", "force invalid activation context");
+
+        assertTextPresent(
+                "Exception: Exception in method org.apache.tapestry.integration.app1.pages.ExceptionEventDemo.onActivate(float)");
+
+        clickAndWait("link=force invalid event context");
+
+        assertTextPresent(
+                "Exception: Exception in method org.apache.tapestry.integration.app1.pages.ExceptionEventDemo.onActionFromFail(float)");
+
+        // Revert to normal handling: return null from the onException() event handler method.
+
+        clickAndWait("link=disable");
+
+        clickAndWait("link=force invalid event context");
+
+        assertTextPresent("An unexpected application exception has occurred.",
+                          "org.apache.tapestry.ioc.internal.util.TapestryException", "java.lang.NumberFormatException");
+
     }
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/EventMethodTranslate.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/EventMethodTranslate.java?rev=614581&r1=614580&r2=614581&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/EventMethodTranslate.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/EventMethodTranslate.java Wed Jan 23 08:44:46 2008
@@ -1,4 +1,4 @@
-// Copyright 2007 The Apache Software Foundation
+// Copyright 2007, 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.
@@ -47,6 +47,8 @@
         // And it gets tricky because we probably should trim spaces!
 
         if (input.equalsIgnoreCase("zero")) return 0;
+
+        if (input.equalsIgnoreCase("i")) throw new ValidationException("Rational numbers only, please.");
 
         // Get the default behavior.
 

Added: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/ExceptionEventDemo.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/ExceptionEventDemo.java?rev=614581&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/ExceptionEventDemo.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/ExceptionEventDemo.java Wed Jan 23 08:44:46 2008
@@ -0,0 +1,71 @@
+// 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.tapestry.integration.app1.pages;
+
+import org.apache.tapestry.annotations.Persist;
+
+public class ExceptionEventDemo
+{
+    @Persist("flash")
+    private String _message;
+
+    @Persist
+    private boolean _intercept = true;
+
+    public Object getInvalidContext()
+    {
+        return "abc";
+    }
+
+    void onActivate(float context)
+    {
+        _message = "Activation context: " + context;
+    }
+
+    void onActionFromFail(float context)
+    {
+        _message = "Event context: " + context;
+    }
+
+    Object onException(Throwable exception)
+    {
+        if (!_intercept) return null;
+
+        _message = "Exception: " + exception.getMessage();
+
+        return this;
+    }
+
+
+    void onActionFromEnable()
+    {
+        _intercept = true;
+    }
+
+    void onActionFromDisable()
+    {
+        _intercept = false;
+    }
+
+    public String getMessage()
+    {
+        return _message;
+    }
+
+    public boolean isIntercept()
+    {
+        return _intercept;
+    }
+}

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/Start.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/Start.java?rev=614581&r1=614580&r2=614581&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/Start.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/Start.java Wed Jan 23 08:44:46 2008
@@ -204,7 +204,9 @@
             new Item("NullStrategyDemo", "Null Field Strategy Demo", "use of the nulls parameter of TextField"),
 
             new Item("OverrideValidationDecorator", "Override Validation Decorator",
-                     "override the default validation decorator"));
+                     "override the default validation decorator"),
+
+            new Item("ExceptionEventDemo", "Exception Event Demo", "handling component event exceptions"));
 
     static
     {

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/TapestryInternalUtilsTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/TapestryInternalUtilsTest.java?rev=614581&r1=614580&r2=614581&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/TapestryInternalUtilsTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/TapestryInternalUtilsTest.java Wed Jan 23 08:44:46 2008
@@ -486,4 +486,6 @@
 
         assertEquals(TapestryInternalUtils.toClassAttributeValue(classes), "fred barney wilma");
     }
+
+
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/bindings/DefaultComponent.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/bindings/DefaultComponent.java?rev=614581&r1=614580&r2=614581&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/bindings/DefaultComponent.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/bindings/DefaultComponent.java Wed Jan 23 08:44:46 2008
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 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.
@@ -54,7 +54,7 @@
     {
     }
 
-    public boolean handleComponentEvent(ComponentEvent event)
+    public boolean dispatchComponentEvent(ComponentEvent event)
     {
         return false;
     }

Copied: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ComponentEventDispatcherTest.java (from r612337, tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ComponentActionDispatcherTest.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ComponentEventDispatcherTest.java?p2=tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ComponentEventDispatcherTest.java&p1=tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ComponentActionDispatcherTest.java&r1=612337&r2=614581&rev=614581&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ComponentActionDispatcherTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ComponentEventDispatcherTest.java Wed Jan 23 08:44:46 2008
@@ -22,12 +22,12 @@
 
 import java.io.IOException;
 
-public class ComponentActionDispatcherTest extends InternalBaseTestCase
+public class ComponentEventDispatcherTest extends InternalBaseTestCase
 {
     @Test
     public void no_dot_or_colon_in_path() throws Exception
     {
-        ComponentActionRequestHandler handler = newComponentActionRequestHandler();
+        ComponentEventRequestHandler handler = newComponentActionRequestHandler();
         Request request = mockRequest();
         Response response = mockResponse();
 
@@ -35,16 +35,16 @@
 
         replay();
 
-        Dispatcher dispatcher = new ComponentActionDispatcher(handler, null);
+        Dispatcher dispatcher = new ComponentEventDispatcher(handler, null);
 
         assertFalse(dispatcher.dispatch(request, response));
 
         verify();
     }
 
-    protected final ComponentActionRequestHandler newComponentActionRequestHandler()
+    protected final ComponentEventRequestHandler newComponentActionRequestHandler()
     {
-        return newMock(ComponentActionRequestHandler.class);
+        return newMock(ComponentEventRequestHandler.class);
     }
 
     @Test
@@ -117,16 +117,16 @@
     @Test
     public void page_activation_context_in_request() throws Exception
     {
-        ComponentActionRequestHandler handler = newComponentActionRequestHandler();
+        ComponentEventRequestHandler handler = newComponentActionRequestHandler();
         Request request = mockRequest();
         Response response = mockResponse();
         ComponentClassResolver resolver = mockComponentClassResolver();
 
-        ComponentActionRequestParameters expectedParameters = new ComponentActionRequestParameters("mypage", "mypage",
-                                                                                                   "", "eventname",
-                                                                                                   new String[]{"alpha",
-                                                                                                                "beta"},
-                                                                                                   new String[0]);
+        ComponentEventRequestParameters expectedParameters = new ComponentEventRequestParameters("mypage", "mypage", "",
+                                                                                                 "eventname",
+                                                                                                 new String[]{"alpha",
+                                                                                                              "beta"},
+                                                                                                 new String[0]);
 
         train_getPath(request, "/mypage:eventname");
 
@@ -140,7 +140,7 @@
 
         replay();
 
-        Dispatcher dispatcher = new ComponentActionDispatcher(handler, resolver);
+        Dispatcher dispatcher = new ComponentEventDispatcher(handler, resolver);
 
         assertTrue(dispatcher.dispatch(request, response));
 
@@ -150,16 +150,15 @@
     @Test
     public void different_active_and_containing_pages() throws Exception
     {
-        ComponentActionRequestHandler handler = newComponentActionRequestHandler();
+        ComponentEventRequestHandler handler = newComponentActionRequestHandler();
         Request request = mockRequest();
         Response response = mockResponse();
         ComponentClassResolver resolver = mockComponentClassResolver();
 
-        ComponentActionRequestParameters expectedParameters = new ComponentActionRequestParameters("activepage",
-                                                                                                   "mypage", "",
-                                                                                                   "eventname",
-                                                                                                   new String[0],
-                                                                                                   new String[0]);
+        ComponentEventRequestParameters expectedParameters = new ComponentEventRequestParameters("activepage", "mypage",
+                                                                                                 "", "eventname",
+                                                                                                 new String[0],
+                                                                                                 new String[0]);
 
         train_getPath(request, "/mypage:eventname");
 
@@ -173,7 +172,7 @@
 
         replay();
 
-        Dispatcher dispatcher = new ComponentActionDispatcher(handler, resolver);
+        Dispatcher dispatcher = new ComponentEventDispatcher(handler, resolver);
 
         assertTrue(dispatcher.dispatch(request, response));
 
@@ -183,7 +182,7 @@
     @Test
     public void request_path_reference_non_existent_page() throws Exception
     {
-        ComponentActionRequestHandler handler = newComponentActionRequestHandler();
+        ComponentEventRequestHandler handler = newComponentActionRequestHandler();
         Request request = mockRequest();
         Response response = mockResponse();
         ComponentClassResolver resolver = mockComponentClassResolver();
@@ -194,7 +193,7 @@
 
         replay();
 
-        Dispatcher dispatcher = new ComponentActionDispatcher(handler, resolver);
+        Dispatcher dispatcher = new ComponentEventDispatcher(handler, resolver);
 
         assertFalse(dispatcher.dispatch(request, response));
 
@@ -204,17 +203,17 @@
     private void test(String requestPath, String containerPageName, String nestedComponentId, String eventType,
                       String... eventContext) throws IOException
     {
-        ComponentActionRequestHandler handler = newComponentActionRequestHandler();
+        ComponentEventRequestHandler handler = newComponentActionRequestHandler();
         Request request = mockRequest();
         Response response = mockResponse();
         ComponentClassResolver resolver = mockComponentClassResolver();
 
-        ComponentActionRequestParameters expectedParameters = new ComponentActionRequestParameters(containerPageName,
-                                                                                                   containerPageName,
-                                                                                                   nestedComponentId,
-                                                                                                   eventType,
-                                                                                                   new String[0],
-                                                                                                   eventContext);
+        ComponentEventRequestParameters expectedParameters = new ComponentEventRequestParameters(containerPageName,
+                                                                                                 containerPageName,
+                                                                                                 nestedComponentId,
+                                                                                                 eventType,
+                                                                                                 new String[0],
+                                                                                                 eventContext);
 
         train_getPath(request, requestPath);
 
@@ -228,7 +227,7 @@
 
         replay();
 
-        Dispatcher dispatcher = new ComponentActionDispatcher(handler, resolver);
+        Dispatcher dispatcher = new ComponentEventDispatcher(handler, resolver);
 
         assertTrue(dispatcher.dispatch(request, response));
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ComponentEventImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ComponentEventImplTest.java?rev=614581&r1=614580&r2=614581&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ComponentEventImplTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ComponentEventImplTest.java Wed Jan 23 08:44:46 2008
@@ -15,6 +15,7 @@
 package org.apache.tapestry.internal.services;
 
 import org.apache.tapestry.ComponentEventCallback;
+import org.apache.tapestry.internal.structure.PageResources;
 import org.apache.tapestry.internal.test.InternalBaseTestCase;
 import org.apache.tapestry.ioc.services.TypeCoercer;
 import org.apache.tapestry.runtime.Component;
@@ -46,7 +47,7 @@
 
         replay();
 
-        ComponentEvent event = new ComponentEventImpl("eventType", "someId", null, handler, _coercer, null);
+        ComponentEvent event = new ComponentEventImpl("eventType", "someId", null, handler, null);
 
         assertTrue(event.matches("eventType", "someId", 0));
         assertFalse(event.matches("foo", "someId", 0));
@@ -61,7 +62,7 @@
 
         replay();
 
-        ComponentEvent event = new ComponentEventImpl("eventType", "someId", null, handler, _coercer, null);
+        ComponentEvent event = new ComponentEventImpl("eventType", "someId", null, handler, null);
 
         assertTrue(event.matches("EVENTTYPE", "someid", 0));
 
@@ -75,7 +76,7 @@
 
         replay();
 
-        ComponentEvent event = new ComponentEventImpl("eventType", "someId", null, handler, _coercer, null);
+        ComponentEvent event = new ComponentEventImpl("eventType", "someId", null, handler, null);
 
         assertTrue(event.matches("eventType", "someId", 0));
 
@@ -90,7 +91,7 @@
         ComponentEventCallback handler = mockComponentEventHandler();
 
         replay();
-        ComponentEvent event = new ComponentEventImpl("eventType", "someId", null, handler, _coercer, null);
+        ComponentEvent event = new ComponentEventImpl("eventType", "someId", null, handler, null);
 
         assertTrue(event.matches("eventtype", "SOMEID", 0));
 
@@ -101,14 +102,14 @@
     public void coerce_context()
     {
         ComponentEventCallback handler = mockComponentEventHandler();
-        ComponentClassCache cache = mockComponentClassCache();
+        PageResources resources = mockPageResources();
 
-        train_forName(cache, "java.lang.Integer", Integer.class);
+        train_toClass(resources, "java.lang.Integer", Integer.class);
+        train_coerce(resources, "27", Integer.class, new Integer(27));
 
         replay();
 
-        ComponentEvent event = new ComponentEventImpl("eventType", "someId", new String[]{"27"}, handler, _coercer,
-                                                      cache);
+        ComponentEvent event = new ComponentEventImpl("eventType", "someId", new String[]{"27"}, handler, resources);
 
         assertEquals(event.coerceContext(0, "java.lang.Integer"), new Integer(27));
 
@@ -123,8 +124,7 @@
 
         replay();
 
-        ComponentEvent event = new ComponentEventImpl("eventType", "someId", new String[]{"27"}, handler, _coercer,
-                                                      null);
+        ComponentEvent event = new ComponentEventImpl("eventType", "someId", new String[]{"27"}, handler, null);
 
         event.setSource(component, "foo.Bar.baz()");
 
@@ -149,8 +149,7 @@
 
         replay();
 
-        ComponentEvent event = new ComponentEventImpl("eventType", "someId", new String[]{"abc"}, handler, _coercer,
-                                                      null);
+        ComponentEvent event = new ComponentEventImpl("eventType", "someId", new String[]{"abc"}, handler, null);
 
         event.setSource(component, "foo.Bar.baz()");
 
@@ -183,7 +182,7 @@
 
         replay();
 
-        ComponentEvent event = new ComponentEventImpl("eventType", "someId", null, handler, _coercer, null);
+        ComponentEvent event = new ComponentEventImpl("eventType", "someId", null, handler, null);
 
         event.setSource(component, methodDescription);
 
@@ -208,7 +207,7 @@
 
         replay();
 
-        ComponentEvent event = new ComponentEventImpl("eventType", "someId", null, handler, _coercer, null);
+        ComponentEvent event = new ComponentEventImpl("eventType", "someId", null, handler, null);
 
         event.setSource(component, methodDescription);
 
@@ -227,7 +226,7 @@
 
         replay();
 
-        ComponentEvent event = new ComponentEventImpl("eventType", "someId", null, handler, _coercer, null);
+        ComponentEvent event = new ComponentEventImpl("eventType", "someId", null, handler, null);
 
         event.setSource(component, "foo.Bar.baz()");
 
@@ -250,7 +249,7 @@
 
         replay();
 
-        ComponentEvent event = new ComponentEventImpl("eventType", "someId", null, handler, _coercer, null);
+        ComponentEvent event = new ComponentEventImpl("eventType", "someId", null, handler, null);
 
         event.setSource(component, "foo.Bar.baz()");
         event.storeResult(result);

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/FieldValidationSupportImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/FieldValidationSupportImplTest.java?rev=614581&r1=614580&r2=614581&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/FieldValidationSupportImplTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/FieldValidationSupportImplTest.java Wed Jan 23 08:44:46 2008
@@ -17,7 +17,6 @@
 import org.apache.tapestry.*;
 import org.apache.tapestry.corelib.internal.InternalMessages;
 import org.apache.tapestry.ioc.Messages;
-import org.apache.tapestry.runtime.ComponentEventException;
 import org.apache.tapestry.services.ValidationMessagesSource;
 import org.apache.tapestry.test.TapestryTestCase;
 import org.easymock.EasyMock;
@@ -122,7 +121,7 @@
         EasyMock.expect(resources.triggerEvent(EasyMock.eq(FieldValidationSupportImpl.PARSE_CLIENT_EVENT),
                                                EasyMock.isA(Object[].class),
                                                EasyMock.isA(ComponentEventCallback.class))).andThrow(
-                new ComponentEventException(ve.getMessage(), null, ve));
+                new RuntimeException(ve));
 
 
         replay();
@@ -151,7 +150,6 @@
         ComponentResources resources = mockComponentResources();
         Translator translator = mockTranslator();
         RuntimeException re = new RuntimeException("Just didn't feel right.");
-        ComponentEventException cee = new ComponentEventException(re.getMessage(), null, re);
         ValidationMessagesSource source = mockValidationMessagesSource();
 
         String clientValue = "abracadabra";
@@ -159,7 +157,7 @@
 
         EasyMock.expect(resources.triggerEvent(EasyMock.eq(FieldValidationSupportImpl.PARSE_CLIENT_EVENT),
                                                EasyMock.isA(Object[].class),
-                                               EasyMock.isA(ComponentEventCallback.class))).andThrow(cee);
+                                               EasyMock.isA(ComponentEventCallback.class))).andThrow(re);
 
 
         replay();
@@ -172,10 +170,9 @@
 
             unreachable();
         }
-        catch (ComponentEventException ex)
+        catch (RuntimeException ex)
         {
-            assertSame(ex, cee);
-            assertSame(ex.getCause(), re);
+            assertSame(ex, re);
         }
 
 
@@ -368,14 +365,14 @@
         Object value = new Object();
 
         ValidationException ve = new ValidationException("Bah!");
-        ComponentEventException cee = new ComponentEventException(ve.getMessage(), null, ve);
+        RuntimeException re = new RuntimeException(ve);
 
         ComponentEventCallback handler = null;
 
         fv.validate(value);
 
         expect(resources.triggerEvent(EasyMock.eq(FieldValidationSupportImpl.VALIDATE_EVENT),
-                                      EasyMock.aryEq(new Object[]{value}), EasyMock.eq(handler))).andThrow(cee);
+                                      EasyMock.aryEq(new Object[]{value}), EasyMock.eq(handler))).andThrow(re);
 
 
         replay();

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/PageElementFactoryImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/PageElementFactoryImplTest.java?rev=614581&r1=614580&r2=614581&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/PageElementFactoryImplTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/PageElementFactoryImplTest.java Wed Jan 23 08:44:46 2008
@@ -19,9 +19,6 @@
 import org.apache.tapestry.dom.MarkupModel;
 import org.apache.tapestry.dom.XMLMarkupModel;
 import org.apache.tapestry.internal.parser.AttributeToken;
-import org.apache.tapestry.internal.parser.StartElementToken;
-import org.apache.tapestry.internal.parser.TextToken;
-import org.apache.tapestry.internal.structure.ComponentPageElement;
 import org.apache.tapestry.internal.structure.PageElement;
 import org.apache.tapestry.internal.test.InternalBaseTestCase;
 import org.apache.tapestry.ioc.Location;
@@ -37,32 +34,6 @@
 {
     private static MarkupModel _xmlModel = new XMLMarkupModel();
 
-    @Test
-    public void start_element()
-    {
-        ComponentInstantiatorSource source = mockComponentInstantiatorSource();
-        ComponentClassResolver resolver = mockComponentClassResolver();
-        MarkupWriter writer = new MarkupWriterImpl();
-        Location l = mockLocation();
-        RenderQueue queue = mockRenderQueue();
-
-        replay();
-
-        PageElementFactory factory = new PageElementFactoryImpl(source, resolver, null, null, null, null);
-        StartElementToken token = new StartElementToken("http://foo.com", "fred", l);
-
-        PageElement element = factory.newStartElement(token);
-
-        element.render(writer, queue);
-
-
-        writer.defineNamespace("http://foo.com", "");
-
-        verify();
-
-        assertEquals(element.toString(), "Start[http://foo.com fred]");
-        assertEquals(writer.toString(), "<fred xmlns=\"http://foo.com\"></fred>");
-    }
 
     @Test
     public void attribute()
@@ -75,7 +46,7 @@
 
         replay();
 
-        PageElementFactory factory = new PageElementFactoryImpl(source, resolver, null, null, null, null);
+        PageElementFactory factory = new PageElementFactoryImpl(source, resolver, null, null, null);
         AttributeToken token = new AttributeToken(null, "name", "value", l);
 
         PageElement element = factory.newAttributeElement(null, token);
@@ -89,98 +60,6 @@
         assertEquals(writer.toString(), "<?xml version=\"1.0\"?>\n<root name=\"value\"/>");
     }
 
-    @Test
-    public void end_element()
-    {
-        ComponentInstantiatorSource source = mockComponentInstantiatorSource();
-        ComponentClassResolver resolver = mockComponentClassResolver();
-        MarkupWriter writer = new MarkupWriterImpl(_xmlModel);
-        RenderQueue queue = mockRenderQueue();
-
-        replay();
-
-        PageElementFactory factory = new PageElementFactoryImpl(source, resolver, null, null, null, null);
-
-        PageElement element = factory.newEndElement();
-
-        writer.element("root");
-        writer.write("before");
-        writer.element("nested");
-
-        element.render(writer, queue);
-
-        writer.write("after");
-
-        verify();
-
-        assertEquals(element.toString(), "End");
-        assertEquals(writer.toString(), "<?xml version=\"1.0\"?>\n<root>before<nested/>after</root>");
-    }
-
-    @Test
-    public void end_element_is_singleton()
-    {
-        ComponentInstantiatorSource source = mockComponentInstantiatorSource();
-        ComponentClassResolver resolver = mockComponentClassResolver();
-
-        replay();
-
-        PageElementFactory factory = new PageElementFactoryImpl(source, resolver, null, null, null, null);
-
-        PageElement element1 = factory.newEndElement();
-        PageElement element2 = factory.newEndElement();
-
-        assertSame(element2, element1);
-
-        verify();
-    }
-
-    @Test
-    public void text_element()
-    {
-        ComponentInstantiatorSource source = mockComponentInstantiatorSource();
-        ComponentClassResolver resolver = mockComponentClassResolver();
-        MarkupWriter writer = new MarkupWriterImpl();
-        Location l = mockLocation();
-        RenderQueue queue = mockRenderQueue();
-
-        replay();
-
-        PageElementFactory factory = new PageElementFactoryImpl(source, resolver, null, null, null, null);
-        TextToken token = new TextToken("some text", l);
-
-        PageElement element = factory.newTextElement(token);
-
-        writer.element("root");
-        element.render(writer, queue);
-
-        verify();
-
-        assertEquals(element.toString(), "Text[some text]");
-        assertEquals(writer.toString(), "<root>some text</root>");
-    }
-
-    @Test
-    public void render_body_element()
-    {
-        ComponentInstantiatorSource source = mockComponentInstantiatorSource();
-        ComponentClassResolver resolver = mockComponentClassResolver();
-        RenderQueue queue = mockRenderQueue();
-        ComponentPageElement component = mockComponentPageElement();
-        MarkupWriter writer = newMock(MarkupWriter.class);
-
-        component.enqueueBeforeRenderBody(queue);
-
-        replay();
-
-        PageElementFactory factory = new PageElementFactoryImpl(source, resolver, null, null, null, null);
-
-        PageElement element = factory.newRenderBodyElement(component);
-
-        element.render(writer, queue);
-
-        verify();
-    }
 
     @Test
     public void unclosed_attribute_expression()
@@ -197,8 +76,7 @@
 
         replay();
 
-        PageElementFactory factory = new PageElementFactoryImpl(source, resolver, typeCoercer, null, bindingSource,
-                                                                messagesSource);
+        PageElementFactory factory = new PageElementFactoryImpl(source, resolver, typeCoercer, bindingSource, null);
 
         try
         {

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/PageLoaderImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/PageLoaderImplTest.java?rev=614581&r1=614580&r2=614581&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/PageLoaderImplTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/PageLoaderImplTest.java Wed Jan 23 08:44:46 2008
@@ -26,6 +26,7 @@
 import org.apache.tapestry.model.ComponentModel;
 import org.apache.tapestry.model.EmbeddedComponentModel;
 import org.apache.tapestry.services.ComponentClassResolver;
+import org.easymock.EasyMock;
 import org.slf4j.Logger;
 import org.testng.annotations.Test;
 
@@ -56,7 +57,7 @@
 
         train_resolvePageNameToClassName(resolver, LOGICAL_PAGE_NAME, PAGE_CLASS_NAME);
 
-        train_newRootComponentElement(elementFactory, PAGE_CLASS_NAME, rootElement);
+        train_newRootComponentElement(elementFactory, PAGE_CLASS_NAME, rootElement, LOCALE);
 
         train_getComponentResources(rootElement, resources);
         train_getComponentModel(resources, model);
@@ -108,7 +109,7 @@
         ComponentClassResolver resolver = mockComponentClassResolver();
 
         train_resolvePageNameToClassName(resolver, LOGICAL_PAGE_NAME, PAGE_CLASS_NAME);
-        train_newRootComponentElement(elementFactory, PAGE_CLASS_NAME, rootElement);
+        train_newRootComponentElement(elementFactory, PAGE_CLASS_NAME, rootElement, LOCALE);
 
         train_getComponentResources(rootElement, resources);
         train_getComponentModel(resources, model);
@@ -156,8 +157,10 @@
         train_getComponentClassName(childModel, CHILD_CLASS_NAME);
         train_getTemplate(templateSource, childModel, LOCALE, childTemplate);
         train_isMissing(childTemplate, true);
-        train_newRenderBodyElement(elementFactory, childElement, body);
-        childElement.addToTemplate(body);
+
+        // This will be the RenderBody element ...
+
+        childElement.addToTemplate(EasyMock.isA(PageElement.class));
 
         replay();