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/01/16 03:33:12 UTC
svn commit: r612337 [2/3] - in /tapestry/tapestry5/trunk/tapestry-core/src:
main/java/org/apache/tapestry/
main/java/org/apache/tapestry/corelib/components/
main/java/org/apache/tapestry/corelib/mixins/
main/java/org/apache/tapestry/internal/ main/java...
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/PageRenderRequestHandlerImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/PageRenderRequestHandlerImpl.java?rev=612337&r1=612336&r2=612337&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/PageRenderRequestHandlerImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/PageRenderRequestHandlerImpl.java Tue Jan 15 18:33:09 2008
@@ -14,14 +14,10 @@
package org.apache.tapestry.internal.services;
-import org.apache.tapestry.ComponentEventHandler;
import org.apache.tapestry.TapestryConstants;
import org.apache.tapestry.internal.structure.Page;
-import org.apache.tapestry.internal.util.Holder;
-import org.apache.tapestry.runtime.Component;
import org.apache.tapestry.services.ComponentEventResultProcessor;
import org.apache.tapestry.services.PageRenderRequestHandler;
-import org.apache.tapestry.services.Response;
import org.apache.tapestry.services.Traditional;
import java.io.IOException;
@@ -37,52 +33,26 @@
private final PageResponseRenderer _pageResponseRenderer;
- private final Response _response;
-
public PageRenderRequestHandlerImpl(RequestPageCache cache,
@Traditional ComponentEventResultProcessor resultProcessor,
- PageResponseRenderer pageResponseRenderer, Response response)
+ PageResponseRenderer pageResponseRenderer)
{
_cache = cache;
_resultProcessor = resultProcessor;
_pageResponseRenderer = pageResponseRenderer;
- _response = response;
}
public void handle(String logicalPageName, String[] context) throws IOException
{
Page page = _cache.get(logicalPageName);
- final Holder<Boolean> holder = Holder.create();
- final Holder<IOException> exceptionHolder = Holder.create();
-
- ComponentEventHandler handler = new ComponentEventHandler()
- {
- @SuppressWarnings("unchecked")
- public boolean handleResult(Object result, Component component, String methodDescription)
- {
- try
- {
- _resultProcessor.processComponentEvent(result, component, methodDescription);
- }
- catch (IOException ex)
- {
- exceptionHolder.put(ex);
- }
-
- holder.put(true);
-
- return true; // abort the event
- }
- };
+ ComponentResultProcessorWrapper callback = new ComponentResultProcessorWrapper(_resultProcessor);
- page.getRootElement().triggerEvent(TapestryConstants.ACTIVATE_EVENT, context, handler);
+ page.getRootElement().triggerEvent(TapestryConstants.ACTIVATE_EVENT, context, callback);
// The handler will have asked the result processor to send a response.
- if (exceptionHolder.hasValue()) throw exceptionHolder.get();
-
- if (holder.hasValue()) return;
+ if (callback.isAborted()) return;
_pageResponseRenderer.renderPageResponse(page);
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/RenderCommandComponentEventResultProcessor.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/RenderCommandComponentEventResultProcessor.java?rev=612337&r1=612336&r2=612337&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/RenderCommandComponentEventResultProcessor.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/RenderCommandComponentEventResultProcessor.java Tue Jan 15 18:33:09 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.
@@ -34,8 +34,7 @@
_renderer = renderer;
}
- public void processComponentEvent(RenderCommand value, Component component, String methodDescripion)
- throws IOException
+ public void processResultValue(RenderCommand value, Component component, String methodDescripion) throws IOException
{
_renderer.renderPartialPageMarkup(value);
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/StreamResponseResultProcessor.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/StreamResponseResultProcessor.java?rev=612337&r1=612336&r2=612337&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/StreamResponseResultProcessor.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/StreamResponseResultProcessor.java Tue Jan 15 18:33:09 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.
@@ -36,7 +36,7 @@
_response = response;
}
- public void processComponentEvent(StreamResponse streamResponse, Component component, String methodDescripion)
+ public void processResultValue(StreamResponse streamResponse, Component component, String methodDescripion)
throws IOException
{
OutputStream os = null;
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/StringResultProcessor.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/StringResultProcessor.java?rev=612337&r1=612336&r2=612337&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/StringResultProcessor.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/StringResultProcessor.java Tue Jan 15 18:33:09 2008
@@ -36,7 +36,7 @@
_generator = generator;
}
- public void processComponentEvent(String value, Component component, String methodDescripion) throws IOException
+ public void processResultValue(String value, Component component, String methodDescripion) throws IOException
{
Page page = _requestPageCache.get(value);
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/ComponentPageElementImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/ComponentPageElementImpl.java?rev=612337&r1=612336&r2=612337&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/ComponentPageElementImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/ComponentPageElementImpl.java Tue Jan 15 18:33:09 2008
@@ -22,7 +22,7 @@
import org.apache.tapestry.internal.services.ComponentEventImpl;
import org.apache.tapestry.internal.services.EventImpl;
import org.apache.tapestry.internal.services.Instantiator;
-import org.apache.tapestry.internal.util.NotificationEventHandler;
+import org.apache.tapestry.internal.util.NotificationEventCallback;
import org.apache.tapestry.ioc.BaseLocatable;
import org.apache.tapestry.ioc.Location;
import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newCaseInsensitiveMap;
@@ -43,15 +43,14 @@
import java.util.Map;
/**
- * Implements {@link org.apache.tapestry.internal.structure.PageElement} and
- * {@link org.apache.tapestry.internal.InternalComponentResources}, and represents a component
- * within an overall page. Much of a component page element's behavior is delegated to user code,
- * via a {@link org.apache.tapestry.runtime.Component} instance.
+ * Implements {@link org.apache.tapestry.internal.structure.PageElement} and {@link
+ * org.apache.tapestry.internal.InternalComponentResources}, and represents a component within an overall page. Much of
+ * a component page element's behavior is delegated to user code, via a {@link org.apache.tapestry.runtime.Component}
+ * instance.
* <p/>
- * Once instantiated, a ComponentPageElementImpl should be registered as a
- * {@link org.apache.tapestry.internal.structure.Page}. This could be done inside the constructors,
- * but that tends to complicate unit tests, so its done by
- * {@link org.apache.tapestry.internal.services.PageElementFactoryImpl}.
+ * Once instantiated, a ComponentPageElementImpl should be registered as a {@link org.apache.tapestry.internal.structure.Page}.
+ * This could be done inside the constructors, but that tends to complicate unit tests, so its done by {@link
+ * org.apache.tapestry.internal.services.PageElementFactoryImpl}.
* <p/>
*/
public class ComponentPageElementImpl extends BaseLocatable implements ComponentPageElement, PageLifecycleListener
@@ -103,7 +102,7 @@
return list == null ? 0 : list.size();
}
- private static class RenderPhaseEventHandler implements ComponentEventHandler
+ private static class RenderPhaseEventHandler implements ComponentEventCallback
{
private boolean _result = true;
@@ -420,9 +419,8 @@
private final ComponentMessagesSource _messagesSource;
/**
- * Component lifecycle instances for all mixins; the core component is added to this list during
- * page load. This is only used in the case that a component has mixins (in which case, the core
- * component is listed last).
+ * Component lifecycle instances for all mixins; the core component is added to this list during page load. This is
+ * only used in the case that a component has mixins (in which case, the core component is listed last).
*/
private List<Component> _components = null;
@@ -495,15 +493,13 @@
private final ComponentClassCache _componentClassCache;
/**
- * Constructor for other components embedded within the root component or at deeper levels of
- * the hierarchy.
+ * Constructor for other components embedded within the root component or at deeper levels of the hierarchy.
*
* @param page ultimately containing this component
* @param container component immediately containing this component (may be null for a root component)
- * @param id unique (within the container) id for this component (may be null for a root
- * component)
- * @param elementName the name of the element which represents this component in the template, or null
- * for <comp> element or a page component
+ * @param id unique (within the container) id for this component (may be null for a root component)
+ * @param elementName the name of the element which represents this component in the template, or null for
+ * <comp> element or a page component
* @param instantiator used to create the new component instance and access the component's model
* @param typeCoercer used when coercing parameter values
* @param messagesSource Provides access to the component's message catalog
@@ -855,8 +851,8 @@
/**
* Invokes a callback on the component instances (the core component plus any mixins).
*
- * @param reverse if true, the callbacks are in the reverse of the normal order (this is associated
- * with AfterXXX phases)
+ * @param reverse if true, the callbacks are in the reverse of the normal order (this is associated with AfterXXX
+ * phases)
* @param callback the object to receive each component instance
*/
private void invoke(boolean reverse, ComponentCallback callback)
@@ -920,7 +916,7 @@
return String.format("ComponentPageElement[%s]", _completeId);
}
- public boolean triggerEvent(String eventType, Object[] context, ComponentEventHandler handler)
+ public boolean triggerEvent(String eventType, Object[] context, ComponentEventCallback callback)
{
boolean result = false;
@@ -928,10 +924,10 @@
String componentId = "";
// Provide a default handler for when the provided handler is null.
- final ComponentEventHandler providedHandler = handler == null ? new NotificationEventHandler(eventType,
- _completeId) : handler;
+ final ComponentEventCallback providedHandler = callback == null ? new NotificationEventCallback(eventType,
+ _completeId) : callback;
- ComponentEventHandler wrappedHandler = new ComponentEventHandler()
+ ComponentEventCallback wrapped = new ComponentEventCallback()
{
public boolean handleResult(Object result, Component component, String methodDescription)
{
@@ -947,7 +943,7 @@
while (component != null)
{
- ComponentEvent event = new ComponentEventImpl(eventType, componentId, context, wrappedHandler, _typeCoercer,
+ ComponentEvent event = new ComponentEventImpl(eventType, componentId, context, wrapped, _typeCoercer,
_componentClassCache);
result |= component.handleEvent(event);
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/InternalComponentResourcesImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/InternalComponentResourcesImpl.java?rev=612337&r1=612336&r2=612337&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/InternalComponentResourcesImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/InternalComponentResourcesImpl.java Tue Jan 15 18:33:09 2008
@@ -39,9 +39,8 @@
import java.util.Map;
/**
- * The bridge between a component and its {@link ComponentPageElement}, that supplies all kinds of
- * resources to the component, including access to its parameters, parameter bindings, and
- * persistent field data.
+ * The bridge between a component and its {@link ComponentPageElement}, that supplies all kinds of resources to the
+ * component, including access to its parameters, parameter bindings, and persistent field data.
*/
public class InternalComponentResourcesImpl implements InternalComponentResources
{
@@ -126,10 +125,8 @@
}
/**
- * Delegates to the
- * {@link Page#createActionLink(String, String, boolean, Object[])} on the containing page.
- * Why the extra layer? Trying to avoid some unwanted injection (of LinkFactory, into every
- * component page element).
+ * Delegates to the {@link Page#createActionLink(String, String, boolean, Object[])} on the containing page. Why the
+ * extra layer? Trying to avoid some unwanted injection (of LinkFactory, into every component page element).
*/
public Link createActionLink(String action, boolean forForm, Object... context)
{
@@ -162,7 +159,7 @@
return _element.isRendering();
}
- public boolean triggerEvent(String eventType, Object[] context, ComponentEventHandler handler)
+ public boolean triggerEvent(String eventType, Object[] context, ComponentEventCallback handler)
{
return _element.triggerEvent(eventType, context, handler);
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/Page.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/Page.java?rev=612337&r1=612336&r2=612337&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/Page.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/Page.java Tue Jan 15 18:33:09 2008
@@ -23,39 +23,36 @@
import java.util.Locale;
/**
- * Represents a unique page within the application. Pages are part of the <em>internal</em>
- * structure of a Tapestry application; end developers who refer to "page" are really referring to
- * the {@link #getRootComponent() root component} of the actual page.
+ * Represents a unique page within the application. Pages are part of the <em>internal</em> structure of a Tapestry
+ * application; end developers who refer to "page" are really referring to the {@link #getRootComponent() root
+ * component} of the actual page.
* <p/>
- * One of the most important aspects of a Page is that it <em>does not</em> have to be coded in a
- * thread-safe manner. Pages are always accessed within a single thread, associated with a single
- * incoming request.
+ * One of the most important aspects of a Page is that it <em>does not</em> have to be coded in a thread-safe manner.
+ * Pages are always accessed within a single thread, associated with a single incoming request.
* <p/>
- * The Page object is never visible to end-user code. The page also exists to provide a kind of
- * service to components embedded (directly or indirectly) within the page.
+ * The Page object is never visible to end-user code. The page also exists to provide a kind of service to components
+ * embedded (directly or indirectly) within the page.
*/
public interface Page
{
/**
- * Returns the short, logical name for the page.
+ * Returns the short, logical name for the page. This is the page name as it might included in an action or page
+ * render URL (though it will be converted to lower case when it is included).
*/
String getLogicalName();
/**
- * The locale for which the page is localized. This is set when the page is created and does not
- * change.
+ * The locale for which the page is localized. This is set when the page is created and does not change.
*/
Locale getLocale();
/**
- * Invoked during page construction time to connect the page's root component to the page
- * instance.
+ * Invoked during page construction time to connect the page's root component to the page instance.
*/
void setRootElement(ComponentPageElement component);
/**
- * The root component of the page. This is the wrapper around the end developer's view of the
- * page.
+ * The root component of the page. This is the wrapper around the end developer's view of the page.
*/
ComponentPageElement getRootElement();
@@ -65,12 +62,12 @@
Component getRootComponent();
/**
- * Invoked to inform the page that it is being detached from the current request. This occurs
- * just before the page is returned to the page pool.
+ * Invoked to inform the page that it is being detached from the current request. This occurs just before the page
+ * is returned to the page pool.
* <p/>
- * A page may be clean or dirty. A page is dirty if its dirty count is greater than zero
- * (meaning that, during the render of the page, some components did not fully render), or if
- * any of its listeners throw an exception from containingPageDidDetech().
+ * A page may be clean or dirty. A page is dirty if its dirty count is greater than zero (meaning that, during the
+ * render of the page, some components did not fully render), or if any of its listeners throw an exception from
+ * containingPageDidDetech().
* <p/>
* The page pool should discard pages that are dirty, rather than store them into the pool.
*
@@ -80,9 +77,9 @@
boolean detached();
/**
- * Invoked to inform the page that it is attached to the current request. This occurs when a
- * page is first referenced within a request. If the page was created from scratch for this
- * request, the call to {@link #loaded()} will preceded the call to {@link #attached()}.
+ * Invoked to inform the page that it is attached to the current request. This occurs when a page is first
+ * referenced within a request. If the page was created from scratch for this request, the call to {@link #loaded()}
+ * will preceded the call to {@link #attached()}.
*/
void attached();
@@ -101,15 +98,15 @@
void addLifecycleListener(PageLifecycleListener listener);
/**
- * Returns the logger of the root component element. Any logging about page construction or
- * activity should be sent to this logger.
+ * Returns the logger of the root component element. Any logging about page construction or activity should be sent
+ * to this logger.
*/
Logger getLogger();
/**
- * Retrieves a component element by its nested id (a sequence of simple ids, separated by dots).
- * The individual names in the nested id are matched without regards to case.
- * A nested id of '' (the empty string) returns the root element of the page.
+ * Retrieves a component element by its nested id (a sequence of simple ids, separated by dots). The individual
+ * names in the nested id are matched without regards to case. A nested id of '' (the empty string) returns the root
+ * element of the page.
*
* @throws IllegalArgumentException if the nestedId does not correspond to a component
*/
@@ -132,8 +129,7 @@
/**
* Posts a change to a persistent field.
*
- * @param resources the component resources for the component or mixin containing the field whose
- * value changed
+ * @param resources the component resources for the component or mixin containing the field whose value changed
* @param fieldName the name of the field
* @param newValue the new value for the field
*/
@@ -149,9 +145,8 @@
Object getFieldChange(String nestedId, String fieldName);
/**
- * Called as a component initially starts to render itself. This is used to check for the cases
- * where a component causes a runtime exception that aborts the render early, leaving the page
- * in an invalid state.
+ * Called as a component initially starts to render itself. This is used to check for the cases where a component
+ * causes a runtime exception that aborts the render early, leaving the page in an invalid state.
*/
void incrementDirtyCount();
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=612337&r1=612336&r2=612337&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 Tue Jan 15 18:33:09 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.
@@ -23,6 +23,7 @@
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 java.io.IOException;
@@ -56,8 +57,8 @@
}
/**
- * Click on the action link and get another link in return. Then follow up the link with another
- * {@link ComponentInvoker}.
+ * Click on the action link and get another link in return. Then follow up the link with another {@link
+ * ComponentInvoker}.
*
* @param invocation The ComponentInvocation object corresponding to the action link.
* @return The DOM created. Typically you will assert against it.
@@ -86,9 +87,20 @@
ActionLinkTarget actionLinkTarget = Defense.cast(target, ActionLinkTarget.class, "target");
- _componentActionRequestHandler.handle(actionLinkTarget.getPageName(), actionLinkTarget
- .getComponentNestedId(), actionLinkTarget.getEventType(), invocation
- .getContext(), invocation.getActivationContext());
+ ComponentActionRequestParameters parameters = new ComponentActionRequestParameters(
+ actionLinkTarget.getPageName(),
+
+ actionLinkTarget.getPageName(),
+
+ actionLinkTarget.getComponentNestedId(),
+
+ actionLinkTarget.getEventType(),
+
+ invocation.getActivationContext(),
+
+ invocation.getContext());
+
+ _componentActionRequestHandler.handle(parameters);
}
catch (IOException e)
{
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/InternalBaseTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/InternalBaseTestCase.java?rev=612337&r1=612336&r2=612337&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/InternalBaseTestCase.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/InternalBaseTestCase.java Tue Jan 15 18:33:09 2008
@@ -573,4 +573,14 @@
{
return newMock(ActionRenderResponseGenerator.class);
}
+
+ protected final PageRenderQueue mockPageRenderQueue()
+ {
+ return newMock(PageRenderQueue.class);
+ }
+
+ protected final void train_getRenderingPage(PageRenderQueue queue, Page page)
+ {
+ expect(queue.getRenderingPage()).andReturn(page);
+ }
}
Copied: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/util/NotificationEventCallback.java (from r594255, tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/util/NotificationEventHandler.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/util/NotificationEventCallback.java?p2=tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/util/NotificationEventCallback.java&p1=tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/util/NotificationEventHandler.java&r1=594255&r2=612337&rev=612337&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/util/NotificationEventHandler.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/util/NotificationEventCallback.java Tue Jan 15 18:33:09 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.
@@ -14,21 +14,20 @@
package org.apache.tapestry.internal.util;
-import org.apache.tapestry.ComponentEventHandler;
+import org.apache.tapestry.ComponentEventCallback;
import org.apache.tapestry.runtime.Component;
/**
- * A {@link ComponentEventHandler} used for notification events. Event handler methods may return
- * true (to abort the event) or false (to allow the event to continue bubbling up), but all other
- * values are forbidden.
+ * A {@link org.apache.tapestry.ComponentEventCallback} used for notification events. Event handler methods may return
+ * true (to abort the event) or false (to allow the event to continue bubbling up), but all other values are forbidden.
*/
-public class NotificationEventHandler implements ComponentEventHandler
+public class NotificationEventCallback implements ComponentEventCallback
{
private final String _eventType;
private final String _completeId;
- public NotificationEventHandler(String eventType, String completeId)
+ public NotificationEventCallback(String eventType, String completeId)
{
_eventType = eventType;
_completeId = completeId;
@@ -36,14 +35,10 @@
public boolean handleResult(Object result, Component component, String methodDescription)
{
- if (result instanceof Boolean)
- return ((Boolean) result);
+ if (result instanceof Boolean) return ((Boolean) result);
- throw new IllegalArgumentException(UtilMessages.noReturnValueAccepted(
- _eventType,
- _completeId,
- result,
- methodDescription));
+ throw new IllegalArgumentException(
+ UtilMessages.noReturnValueAccepted(_eventType, _completeId, result, methodDescription));
}
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/runtime/ComponentEvent.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/runtime/ComponentEvent.java?rev=612337&r1=612336&r2=612337&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/runtime/ComponentEvent.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/runtime/ComponentEvent.java Tue Jan 15 18:33:09 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.
@@ -14,16 +14,14 @@
package org.apache.tapestry.runtime;
-import org.apache.tapestry.ComponentEventHandler;
import org.apache.tapestry.ComponentResourcesCommon;
/**
- * An event that may originate in application logic, or as a result of a client interaction (a GET
- * or POST from the client).
+ * An event that may originate in application logic, or as a result of a client interaction (a GET or POST from the
+ * client).
*
- * @see ComponentResourcesCommon#triggerEvent(String, Object[],
- * org.apache.tapestry.ComponentEventHandler)
- * @see ComponentEventHandler
+ * @see ComponentResourcesCommon#triggerEvent(String, Object[], org.apache.tapestry.ComponentEventCallback)
+ * @see org.apache.tapestry.ComponentEventCallback
*/
public interface ComponentEvent extends Event
{
@@ -38,8 +36,8 @@
boolean matches(String eventType, String componentId, int parameterCount);
/**
- * Coerces a context value to a particular type. The context is an array of objects; typically
- * it is an array of strings of extra path information encoded into the action URL.
+ * Coerces a context value to a particular type. The context is an array of objects; typically it is an array of
+ * strings of extra path information encoded into the action URL.
*
* @param index the index of the context value
* @param desiredTypeName the desired type
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/runtime/Event.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/runtime/Event.java?rev=612337&r1=612336&r2=612337&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/runtime/Event.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/runtime/Event.java Tue Jan 15 18:33:09 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.
@@ -14,28 +14,26 @@
package org.apache.tapestry.runtime;
-import org.apache.tapestry.ComponentEventHandler;
-
/**
- * The core methods related to event handling. Events used in this way exist to gather data from
- * user code, by invoking user methods and capturing the response. Return values from methods, if
- * non-null, are passed to a {@link ComponentEventHandler}. The {@link ComponentEvent} subinterface
- * extends this by providing access to a context, or set of information related to the event, along
- * with additional data used, at runtime, to match events to user code methods.
+ * The core methods related to event handling. Events used in this way exist to gather data from user code, by invoking
+ * user methods and capturing the response. Return values from methods, if non-null, are passed to a {@link
+ * org.apache.tapestry.ComponentEventCallback}. The {@link ComponentEvent} subinterface extends this by providing access
+ * to a context, or set of information related to the event, along with additional data used, at runtime, to match
+ * events to user code methods.
*/
public interface Event
{
/**
- * Returns true if the event has been aborted (meaning that the return value from some event
- * handler method was accepted, and processing of the event was terminated).
+ * Returns true if the event has been aborted (meaning that the return value from some event handler method was
+ * accepted, and processing of the event was terminated).
*
* @return true if no further event handler methods should be invoked
*/
boolean isAborted();
/**
- * Invoke to identify, to the event, what component and method is being acted upon (used for
- * some kinds of exception reporting).
+ * Invoke to identify, to the event, what component and method is being acted upon (used for some kinds of exception
+ * reporting).
*
* @param component the component instance from which the result was obtained
* @param methodDescription describes the location (i.e. file name, method name and line number) of the method
@@ -43,8 +41,8 @@
void setSource(Component component, String methodDescription);
/**
- * Stores a result for the event. Storing a non-null result value may abort the event (at the
- * discretion of the {@link ComponentEventHandler}).
+ * Stores a result for the event. Storing a non-null result value may abort the event (at the discretion of the
+ * {@link org.apache.tapestry.ComponentEventCallback}).
*
* @param result the result obtained from a method invocations
* @return true if the event is now aborted
Modified: 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/ComponentActionRequestFilter.java?rev=612337&r1=612336&r2=612337&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/ComponentActionRequestFilter.java Tue Jan 15 18:33:09 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.
@@ -19,21 +19,17 @@
/**
* Filter interface for {@link ComponentActionRequestHandler}.
*
- * @see org.apache.tapestry.services.TapestryModule#contributeComponentActionRequestHandler(org.apache.tapestry.ioc.OrderedConfiguration, org.apache.tapestry.internal.services.RequestEncodingInitializer, ComponentActionRequestHandler)
+ * @see org.apache.tapestry.services.TapestryModule#contributeComponentActionRequestHandler(org.apache.tapestry.ioc.OrderedConfiguration,
+ * org.apache.tapestry.internal.services.RequestEncodingInitializer, ComponentActionRequestHandler,
+ * org.apache.tapestry.ioc.ObjectLocator) }
*/
public interface ComponentActionRequestFilter
{
/**
* Filter for a component action request.
*
- * @param logicalPageName the page name containing the component, and the default component to render the
- * response
- * @param nestedComponentId the id of the component within the page
- * @param eventType the type of event to trigger on the component
- * @param context context information to provide to the event handler
- * @param activationContext activation context for the page
- * @param handler to delegate to
+ * @param parameters defining details of the request
+ * @param handler to delegate to
*/
- void handle(String logicalPageName, String nestedComponentId, String eventType, String[] context,
- String[] activationContext, ComponentActionRequestHandler handler) throws IOException;
+ void handle(ComponentActionRequestParameters parameters, ComponentActionRequestHandler handler) throws IOException;
}
Modified: 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/ComponentActionRequestHandler.java?rev=612337&r1=612336&r2=612337&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/ComponentActionRequestHandler.java Tue Jan 15 18:33:09 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.
@@ -20,9 +20,9 @@
import java.io.IOException;
/**
- * Handler interface for action requests. Action requests <em>do things</em> such as process a
- * form submission or otherwise change state. In the majority of cases, after the action, a redirect
- * response is sent to the client which, in turn, causes a page render.
+ * Handler interface for action requests. Action requests <em>do things</em> such as process a form submission or
+ * otherwise change state. In the majority of cases, after the action, a redirect response is sent to the client which,
+ * in turn, causes a page render.
*
* @see ActionLink
* @see Form
@@ -31,16 +31,10 @@
public interface ComponentActionRequestHandler
{
/**
- * Handler for a component action request which will trigger an event on a component and use
- * the return value to send a response to the client (typically, a redirect to a page render URL).
+ * Handler for a component action request which will trigger an event on a component and use the return value to
+ * send a response to the client (typically, a redirect to a page render URL).
*
- * @param logicalPageName the page name containing the component, and the default component to render the
- * response
- * @param nestedComponentId the id of the component within the page
- * @param eventType the type of event to trigger on the component
- * @param context context information to provide to the event handler
- * @param activationContext activation context for the page
+ * @param parameters defining the requst
*/
- void handle(String logicalPageName, String nestedComponentId, String eventType, String[] context,
- String[] activationContext) throws IOException;
+ void handle(ComponentActionRequestParameters parameters) throws IOException;
}
Added: 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/ComponentActionRequestParameters.java?rev=612337&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/ComponentActionRequestParameters.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/ComponentActionRequestParameters.java Tue Jan 15 18:33:09 2008
@@ -0,0 +1,125 @@
+// 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.services;
+
+import org.apache.tapestry.ioc.internal.util.Defense;
+
+import java.util.Arrays;
+
+/**
+ * Encapsulates all the information that may be provided in a component action request URL.
+ */
+public final class ComponentActionRequestParameters
+{
+ private final String _activePageName;
+ private final String _containingPageName;
+ private final String _nestedComponentId;
+ private final String _eventType;
+ private final String[] _pageActivationContext;
+ private final String[] _eventContext;
+
+ public ComponentActionRequestParameters(String activePageName, String containingPageName, String nestedComponentId,
+ String eventType, String[] pageActivationContext, String[] eventContext)
+ {
+ Defense.notBlank(activePageName, "activePageName");
+ Defense.notBlank(containingPageName, "containingPageName");
+ Defense.notNull(nestedComponentId, "nestedComponentId");
+ Defense.notBlank(eventType, "eventType");
+ Defense.notNull(pageActivationContext, "pageActivationContext");
+ Defense.notNull(eventContext, "eventContext");
+
+ _activePageName = activePageName;
+ _containingPageName = containingPageName;
+ _nestedComponentId = nestedComponentId;
+ _eventType = eventType;
+ _pageActivationContext = pageActivationContext;
+ _eventContext = eventContext;
+ }
+
+ // Implements equals() as a convienience for testing.
+
+ public boolean equals(Object o)
+ {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ ComponentActionRequestParameters that = (ComponentActionRequestParameters) o;
+
+ if (!_activePageName.equals(that._activePageName)) return false;
+ if (!_containingPageName.equals(that._containingPageName)) return false;
+ if (!Arrays.equals(_eventContext, that._eventContext)) return false;
+ if (!_eventType.equals(that._eventType)) return false;
+ if (!_nestedComponentId.equals(that._nestedComponentId)) return false;
+
+ return Arrays.equals(_pageActivationContext, that._pageActivationContext);
+ }
+
+
+ /**
+ * The name of the active page which rendered the link. This is usually, but not always, the page which contains
+ * the component.
+ */
+ public String getActivePageName()
+ {
+ return _activePageName;
+ }
+
+ /**
+ * The name of the page containing the component that was triggered. Usually this is the same as the active page,
+ * but because of {@link org.apache.tapestry.Block} and similar constructs, a component from other than the active
+ * page may be rendered with the active page.
+ */
+ public String getContainingPageName()
+ {
+ return _containingPageName;
+ }
+
+ /**
+ * The path from the containing page down to the component in question. This may be the empty string if the action
+ * request is routed directly to the page rather than a component.
+ */
+ public String getNestedComponentId()
+ {
+ return _nestedComponentId;
+ }
+
+ /**
+ * The type of event. When not specified in the URL, a default type of "action" ({@link
+ * org.apache.tapestry.TapestryConstants#ACTION_EVENT}) is provided.
+ */
+ public String getEventType()
+ {
+ return _eventType;
+ }
+
+ /**
+ * The activation context for the <em>active page</em>, possibly empty (but not null).
+ */
+ public String[] getPageActivationContext()
+ {
+ return _pageActivationContext;
+ }
+
+ /**
+ * The event context information passed in the URL. Possibly empty (not not null).
+ *
+ * @see org.apache.tapestry.ComponentResourcesCommon#triggerEvent(String, Object[],
+ * org.apache.tapestry.ComponentEventCallback)
+ */
+ public String[] getEventContext()
+ {
+ return _eventContext;
+ }
+}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/ComponentEventResultProcessor.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/ComponentEventResultProcessor.java?rev=612337&r1=612336&r2=612337&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/ComponentEventResultProcessor.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/ComponentEventResultProcessor.java Tue Jan 15 18:33:09 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.
@@ -33,5 +33,5 @@
* @param methodDescripion a description of method which provided the value
* @throws RuntimeException if the value can not handled
*/
- void processComponentEvent(T value, Component component, String methodDescripion) throws IOException;
+ void processResultValue(T value, Component component, String methodDescripion) 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=612337&r1=612336&r2=612337&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 Tue Jan 15 18:33:09 2008
@@ -1093,8 +1093,7 @@
{
configuration.add(Link.class, new ComponentEventResultProcessor<Link>()
{
- public void processComponentEvent(Link value, Component component, String methodDescripion)
- throws IOException
+ public void processResultValue(Link value, Component component, String methodDescripion) throws IOException
{
_response.sendRedirect(value);
}
@@ -1102,8 +1101,7 @@
configuration.add(URL.class, new ComponentEventResultProcessor<URL>()
{
- public void processComponentEvent(URL value, Component component, String methodDescripion)
- throws IOException
+ public void processResultValue(URL value, Component component, String methodDescripion) throws IOException
{
_response.sendRedirect(value.toExternalForm());
}
@@ -2019,14 +2017,13 @@
{
ComponentActionRequestFilter requestEncodingFilter = new ComponentActionRequestFilter()
{
- public void handle(String logicalPageName, String nestedComponentId, String eventType, String[] context,
- String[] activationContext, ComponentActionRequestHandler handler) throws IOException
+ public void handle(ComponentActionRequestParameters parameters, ComponentActionRequestHandler handler)
+ throws IOException
{
- encodingInitializer.initializeRequestEncoding(logicalPageName);
+ encodingInitializer.initializeRequestEncoding(parameters.getActivePageName());
- handler.handle(logicalPageName, nestedComponentId, eventType, context, activationContext);
+ handler.handle(parameters);
}
-
};
configuration.add("SetRequestEncoding", requestEncodingFilter, "before:*");
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/TapestryTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/TapestryTestCase.java?rev=612337&r1=612336&r2=612337&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/TapestryTestCase.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/TapestryTestCase.java Tue Jan 15 18:33:09 2008
@@ -143,9 +143,9 @@
return newMock(ComponentClassResolver.class);
}
- protected final ComponentEventHandler mockComponentEventHandler()
+ protected final ComponentEventCallback mockComponentEventHandler()
{
- return newMock(ComponentEventHandler.class);
+ return newMock(ComponentEventCallback.class);
}
protected final ComponentModel mockComponentModel()
@@ -709,7 +709,7 @@
}
@SuppressWarnings("unchecked")
- protected final void train_handleResult(ComponentEventHandler handler, Object result, Component component,
+ protected final void train_handleResult(ComponentEventCallback handler, Object result, Component component,
String methodDescription, boolean abort)
{
expect(handler.handleResult(result, component, methodDescription)).andReturn(abort);
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/BlockCaller.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/BlockCaller.tml?rev=612337&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/BlockCaller.tml (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/BlockCaller.tml Tue Jan 15 18:33:09 2008
@@ -0,0 +1,21 @@
+<html t:type="Border" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+
+ <h1>Block Caller Demo</h1>
+
+ <p>This page demonstrates how action links can work correctly even when located outside the
+ active page.
+ </p>
+
+ <p>
+ Page activation context:
+ <span id="context">${activationContext}</span>
+ </p>
+
+
+ <t:delegate to="block"/>
+
+ <p>
+ [<t:pagelink page="blockcaller">refresh</t:pagelink>]
+ </p>
+
+</html>
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/BlockHolder.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/BlockHolder.tml?rev=612337&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/BlockHolder.tml (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/BlockHolder.tml Tue Jan 15 18:33:09 2008
@@ -0,0 +1,11 @@
+<t:container xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+
+ <t:block id="links">
+ <ul>
+ <li t:type="loop" t:source="1..3" value="index">
+ <t:actionlink t:id="link" context="index">${index}</t:actionlink>
+ </li>
+ </ul>
+ </t:block>
+
+</t:container>
\ No newline at end of file
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=612337&r1=612336&r2=612337&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 Tue Jan 15 18:33:09 2008
@@ -1363,4 +1363,33 @@
assertText("//p[@id='true']", "");
}
+
+ /**
+ * TAPESTRY-2044
+ */
+ @Test
+ public void action_links_on_non_active_page()
+ {
+ start("Action Links off of Active Page");
+
+ String contextSpan = "//span[@id='context']";
+
+ assertText(contextSpan, "0");
+
+ clickAndWait("link=3");
+
+ assertText(contextSpan, "3");
+
+ clickAndWait("link=refresh");
+
+ assertText(contextSpan, "3");
+
+ clickAndWait("link=1");
+
+ assertText(contextSpan, "1");
+
+ clickAndWait("link=refresh");
+
+ assertText(contextSpan, "1");
+ }
}
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/BlockCaller.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/BlockCaller.java?rev=612337&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/BlockCaller.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/BlockCaller.java Tue Jan 15 18:33:09 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.integration.app1.pages;
+
+import org.apache.tapestry.Block;
+import org.apache.tapestry.annotations.InjectPage;
+
+/**
+ * Part of testing for TAPESTRY-2044
+ */
+public class BlockCaller
+{
+ @InjectPage
+ private BlockHolder _blockHolder;
+
+ private int _activationContext;
+
+ public void setActivationContext(int value)
+ {
+ _activationContext = value;
+ }
+
+ public int getActivationContext()
+ {
+ return _activationContext;
+ }
+
+ void onActivate(int activationContext)
+ {
+ _activationContext = activationContext;
+ }
+
+ int onPassivate()
+ {
+ return _activationContext;
+ }
+
+ public Block getBlock()
+ {
+ return _blockHolder.getLinks();
+ }
+}
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/BlockHolder.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/BlockHolder.java?rev=612337&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/BlockHolder.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/BlockHolder.java Tue Jan 15 18:33:09 2008
@@ -0,0 +1,51 @@
+// 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.Block;
+import org.apache.tapestry.annotations.InjectPage;
+import org.apache.tapestry.ioc.annotations.Inject;
+
+public class BlockHolder
+{
+ @InjectPage
+ private BlockCaller _blockCaller;
+
+
+ @Inject
+ private Block _links;
+
+ private int _index;
+
+ public int getIndex()
+ {
+ return _index;
+ }
+
+ public void setIndex(int index)
+ {
+ _index = index;
+ }
+
+ void onActionFromLink(int eventContext)
+ {
+ _blockCaller.setActivationContext(eventContext);
+ }
+
+ Block getLinks()
+ {
+ return _links;
+ }
+}
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=612337&r1=612336&r2=612337&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 Tue Jan 15 18:33:09 2008
@@ -193,6 +193,9 @@
new Item("leangriddemo", "Lean Grid Demo",
"Grid component with lean parameter turned on, to eliminate CSS class attributes in TD and TH elements"),
+ new Item("blockcaller", "Action Links off of Active Page",
+ "Actions can exist on pages other than the active page, via Blocks."),
+
new Item("unlessdemo", "Unless Demo", "use of the Unless component"));
static
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/AjaxComponentInstanceEventResultProcessorTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/AjaxComponentInstanceEventResultProcessorTest.java?rev=612337&r1=612336&r2=612337&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/AjaxComponentInstanceEventResultProcessorTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/AjaxComponentInstanceEventResultProcessorTest.java Tue Jan 15 18:33:09 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.
@@ -53,7 +53,7 @@
ComponentEventResultProcessor<Component> processor = new AjaxComponentInstanceEventResultProcessor(renderer,
cache);
- processor.processComponentEvent(component, null, null);
+ processor.processResultValue(component, null, null);
verify();
}
@@ -84,7 +84,7 @@
ComponentEventResultProcessor<Component> processor = new AjaxComponentInstanceEventResultProcessor(renderer,
cache);
- processor.processComponentEvent(component, null, null);
+ processor.processResultValue(component, null, null);
verify();
}
Modified: 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/ComponentActionDispatcherTest.java?rev=612337&r1=612336&r2=612337&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/ComponentActionDispatcherTest.java Tue Jan 15 18:33:09 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,8 +18,6 @@
import org.apache.tapestry.internal.InternalConstants;
import org.apache.tapestry.internal.test.InternalBaseTestCase;
import org.apache.tapestry.services.*;
-import static org.easymock.EasyMock.aryEq;
-import static org.easymock.EasyMock.eq;
import org.testng.annotations.Test;
import java.io.IOException;
@@ -124,14 +122,54 @@
Response response = mockResponse();
ComponentClassResolver resolver = mockComponentClassResolver();
+ ComponentActionRequestParameters expectedParameters = new ComponentActionRequestParameters("mypage", "mypage",
+ "", "eventname",
+ new String[]{"alpha",
+ "beta"},
+ new String[0]);
+
train_getPath(request, "/mypage:eventname");
train_isPageName(resolver, "mypage", true);
train_getParameter(request, InternalConstants.PAGE_CONTEXT_NAME, "alpha/beta");
- handler.handle(eq("mypage"), eq(""), eq("eventname"), aryEq(new String[0]),
- aryEq(new String[]{"alpha", "beta"}));
+ train_getParameter(request, InternalConstants.ACTIVE_PAGE_NAME, null);
+
+ handler.handle(expectedParameters);
+
+ replay();
+
+ Dispatcher dispatcher = new ComponentActionDispatcher(handler, resolver);
+
+ assertTrue(dispatcher.dispatch(request, response));
+
+ verify();
+ }
+
+ @Test
+ public void different_active_and_containing_pages() throws Exception
+ {
+ ComponentActionRequestHandler handler = newComponentActionRequestHandler();
+ Request request = mockRequest();
+ Response response = mockResponse();
+ ComponentClassResolver resolver = mockComponentClassResolver();
+
+ ComponentActionRequestParameters expectedParameters = new ComponentActionRequestParameters("activepage",
+ "mypage", "",
+ "eventname",
+ new String[0],
+ new String[0]);
+
+ train_getPath(request, "/mypage:eventname");
+
+ train_isPageName(resolver, "mypage", true);
+
+ train_getParameter(request, InternalConstants.PAGE_CONTEXT_NAME, null);
+
+ train_getParameter(request, InternalConstants.ACTIVE_PAGE_NAME, "activepage");
+
+ handler.handle(expectedParameters);
replay();
@@ -163,21 +201,30 @@
verify();
}
- private void test(String requestPath, String logicalPageName, String nestedComponentId, String eventType,
- String... context) throws IOException
+ private void test(String requestPath, String containerPageName, String nestedComponentId, String eventType,
+ String... eventContext) throws IOException
{
ComponentActionRequestHandler handler = newComponentActionRequestHandler();
Request request = mockRequest();
Response response = mockResponse();
ComponentClassResolver resolver = mockComponentClassResolver();
+ ComponentActionRequestParameters expectedParameters = new ComponentActionRequestParameters(containerPageName,
+ containerPageName,
+ nestedComponentId,
+ eventType,
+ new String[0],
+ eventContext);
+
train_getPath(request, requestPath);
- train_isPageName(resolver, logicalPageName, true);
+ train_isPageName(resolver, containerPageName, true);
train_getParameter(request, InternalConstants.PAGE_CONTEXT_NAME, null);
- handler.handle(eq(logicalPageName), eq(nestedComponentId), eq(eventType), aryEq(context), aryEq(new String[0]));
+ train_getParameter(request, InternalConstants.ACTIVE_PAGE_NAME, null);
+
+ handler.handle(expectedParameters);
replay();
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=612337&r1=612336&r2=612337&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 Tue Jan 15 18:33:09 2008
@@ -14,7 +14,7 @@
package org.apache.tapestry.internal.services;
-import org.apache.tapestry.ComponentEventHandler;
+import org.apache.tapestry.ComponentEventCallback;
import org.apache.tapestry.internal.test.InternalBaseTestCase;
import org.apache.tapestry.ioc.services.TypeCoercer;
import org.apache.tapestry.runtime.Component;
@@ -42,7 +42,7 @@
@Test
public void matches_on_event_type()
{
- ComponentEventHandler handler = mockComponentEventHandler();
+ ComponentEventCallback handler = mockComponentEventHandler();
replay();
@@ -57,7 +57,7 @@
@Test
public void event_type_match_is_case_insensitive()
{
- ComponentEventHandler handler = mockComponentEventHandler();
+ ComponentEventCallback handler = mockComponentEventHandler();
replay();
@@ -71,7 +71,7 @@
@Test
public void matches_on_component_id()
{
- ComponentEventHandler handler = mockComponentEventHandler();
+ ComponentEventCallback handler = mockComponentEventHandler();
replay();
@@ -87,7 +87,7 @@
@Test
public void component_id_matches_are_case_insensitive()
{
- ComponentEventHandler handler = mockComponentEventHandler();
+ ComponentEventCallback handler = mockComponentEventHandler();
replay();
ComponentEvent event = new ComponentEventImpl("eventType", "someId", null, handler, _coercer, null);
@@ -100,7 +100,7 @@
@Test
public void coerce_context()
{
- ComponentEventHandler handler = mockComponentEventHandler();
+ ComponentEventCallback handler = mockComponentEventHandler();
ComponentClassCache cache = mockComponentClassCache();
train_forName(cache, "java.lang.Integer", Integer.class);
@@ -118,7 +118,7 @@
@Test
public void coerce_when_not_enough_context()
{
- ComponentEventHandler handler = mockComponentEventHandler();
+ ComponentEventCallback handler = mockComponentEventHandler();
Component component = mockComponent();
replay();
@@ -144,7 +144,7 @@
@Test
public void unable_to_coerce()
{
- ComponentEventHandler handler = mockComponentEventHandler();
+ ComponentEventCallback handler = mockComponentEventHandler();
Component component = mockComponent();
replay();
@@ -177,7 +177,7 @@
String methodDescription = "foo.Bar.baz()";
Component component = mockComponent();
- ComponentEventHandler handler = mockComponentEventHandler();
+ ComponentEventCallback handler = mockComponentEventHandler();
train_handleResult(handler, result, component, methodDescription, true);
@@ -202,7 +202,7 @@
Object result = new Object();
String methodDescription = "foo.Bar.baz()";
Component component = mockComponent();
- ComponentEventHandler handler = mockComponentEventHandler();
+ ComponentEventCallback handler = mockComponentEventHandler();
train_handleResult(handler, result, component, methodDescription, false);
@@ -223,7 +223,7 @@
public void store_null_result_does_not_abort_or_invoke_handler()
{
Component component = mockComponent();
- ComponentEventHandler handler = mockComponentEventHandler();
+ ComponentEventCallback handler = mockComponentEventHandler();
replay();
@@ -243,7 +243,7 @@
public void store_result_when_aborted_is_failure()
{
Object result = new Object();
- ComponentEventHandler handler = mockComponentEventHandler();
+ ComponentEventCallback handler = mockComponentEventHandler();
Component component = mockComponent();
expect(handler.handleResult(result, component, "foo.Bar.baz()")).andReturn(true);
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ComponentInstanceResultProcessorTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ComponentInstanceResultProcessorTest.java?rev=612337&r1=612336&r2=612337&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ComponentInstanceResultProcessorTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ComponentInstanceResultProcessorTest.java Tue Jan 15 18:33:09 2008
@@ -52,7 +52,7 @@
ComponentEventResultProcessor<Component> processor = new ComponentInstanceResultProcessor(logger, cache,
generator);
- processor.processComponentEvent(result, source, METHOD_DESCRIPTION);
+ processor.processResultValue(result, source, METHOD_DESCRIPTION);
verify();
}
@@ -92,7 +92,7 @@
ComponentEventResultProcessor<Component> processor = new ComponentInstanceResultProcessor(logger, cache,
generator);
- processor.processComponentEvent(value, source, METHOD_DESCRIPTION);
+ processor.processResultValue(value, source, METHOD_DESCRIPTION);
verify();
}
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=612337&r1=612336&r2=612337&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 Tue Jan 15 18:33:09 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,7 +47,7 @@
{
Object[] args = EasyMock.getCurrentArguments();
Object[] context = (Object[]) args[1];
- ComponentEventHandler handler = (ComponentEventHandler) args[2];
+ ComponentEventCallback handler = (ComponentEventCallback) args[2];
// Pretend that the parser event handler converted it to upper case.
@@ -57,7 +57,7 @@
EasyMock.expect(resources.triggerEvent(EasyMock.eq(FieldValidationSupportImpl.PARSE_CLIENT_EVENT),
EasyMock.isA(Object[].class),
- EasyMock.isA(ComponentEventHandler.class))).andAnswer(answer);
+ EasyMock.isA(ComponentEventCallback.class))).andAnswer(answer);
replay();
@@ -86,7 +86,7 @@
EasyMock.expect(resources.triggerEvent(EasyMock.eq(FieldValidationSupportImpl.PARSE_CLIENT_EVENT),
EasyMock.isA(Object[].class),
- EasyMock.isA(ComponentEventHandler.class))).andThrow(
+ EasyMock.isA(ComponentEventCallback.class))).andThrow(
new ComponentEventException(ve.getMessage(), null, ve));
@@ -124,7 +124,7 @@
EasyMock.expect(resources.triggerEvent(EasyMock.eq(FieldValidationSupportImpl.PARSE_CLIENT_EVENT),
EasyMock.isA(Object[].class),
- EasyMock.isA(ComponentEventHandler.class))).andThrow(cee);
+ EasyMock.isA(ComponentEventCallback.class))).andThrow(cee);
replay();
@@ -161,7 +161,7 @@
EasyMock.expect(resources.triggerEvent(EasyMock.eq(FieldValidationSupportImpl.PARSE_CLIENT_EVENT),
EasyMock.isA(Object[].class),
- EasyMock.isA(ComponentEventHandler.class))).andReturn(false);
+ EasyMock.isA(ComponentEventCallback.class))).andReturn(false);
train_getLocale(resources, locale);
@@ -193,7 +193,7 @@
EasyMock.expect(resources.triggerEvent(EasyMock.eq(FieldValidationSupportImpl.TO_CLIENT_EVENT),
EasyMock.aryEq(new Object[]{value}),
- EasyMock.isA(ComponentEventHandler.class))).andReturn(false);
+ EasyMock.isA(ComponentEventCallback.class))).andReturn(false);
expect(translator.toClient(value)).andReturn(clientValue);
@@ -225,7 +225,7 @@
public Object answer() throws Throwable
{
Object[] args = EasyMock.getCurrentArguments();
- ComponentEventHandler handler = (ComponentEventHandler) args[2];
+ ComponentEventCallback handler = (ComponentEventCallback) args[2];
return handler.handleResult(clientValue, null, null);
}
@@ -233,7 +233,7 @@
EasyMock.expect(resources.triggerEvent(EasyMock.eq(FieldValidationSupportImpl.TO_CLIENT_EVENT),
EasyMock.aryEq(new Object[]{value}),
- EasyMock.isA(ComponentEventHandler.class))).andAnswer(answer);
+ EasyMock.isA(ComponentEventCallback.class))).andAnswer(answer);
replay();
@@ -261,7 +261,7 @@
public Object answer() throws Throwable
{
Object[] args = EasyMock.getCurrentArguments();
- ComponentEventHandler handler = (ComponentEventHandler) args[2];
+ ComponentEventCallback handler = (ComponentEventCallback) args[2];
// Return an innappropriate value.
@@ -271,7 +271,7 @@
EasyMock.expect(resources.triggerEvent(EasyMock.eq(FieldValidationSupportImpl.TO_CLIENT_EVENT),
EasyMock.aryEq(new Object[]{value}),
- EasyMock.isA(ComponentEventHandler.class))).andAnswer(answer);
+ EasyMock.isA(ComponentEventCallback.class))).andAnswer(answer);
replay();
@@ -307,7 +307,7 @@
fv.validate(value);
- ComponentEventHandler handler = null;
+ ComponentEventCallback handler = null;
expect(resources.triggerEvent(EasyMock.eq(FieldValidationSupportImpl.VALIDATE_EVENT),
EasyMock.aryEq(new Object[]{value}), EasyMock.eq(handler))).andReturn(true);
@@ -335,7 +335,7 @@
ValidationException ve = new ValidationException("Bah!");
ComponentEventException cee = new ComponentEventException(ve.getMessage(), null, ve);
- ComponentEventHandler handler = null;
+ ComponentEventCallback handler = null;
fv.validate(value);
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/LinkFactoryImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/LinkFactoryImplTest.java?rev=612337&r1=612336&r2=612337&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/LinkFactoryImplTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/LinkFactoryImplTest.java Tue Jan 15 18:33:09 2008
@@ -14,7 +14,7 @@
package org.apache.tapestry.internal.services;
-import org.apache.tapestry.ComponentEventHandler;
+import org.apache.tapestry.ComponentEventCallback;
import org.apache.tapestry.Link;
import org.apache.tapestry.TapestryConstants;
import org.apache.tapestry.internal.InternalConstants;
@@ -114,7 +114,7 @@
replay();
- LinkFactory factory = new LinkFactoryImpl(request, response, map, null, _typeCoercer, optimizer);
+ LinkFactory factory = new LinkFactoryImpl(request, response, map, null, _typeCoercer, optimizer, null);
factory.addListener(listener);
@@ -158,7 +158,7 @@
replay();
- LinkFactory factory = new LinkFactoryImpl(request, response, map, null, _typeCoercer, optimizer);
+ LinkFactory factory = new LinkFactoryImpl(request, response, map, null, _typeCoercer, optimizer, null);
factory.addListener(listener);
Link link = factory.createPageLink(page, false, "biff", "bazz");
@@ -201,7 +201,7 @@
replay();
- LinkFactory factory = new LinkFactoryImpl(request, response, map, null, _typeCoercer, optimizer);
+ LinkFactory factory = new LinkFactoryImpl(request, response, map, null, _typeCoercer, optimizer, null);
factory.addListener(listener);
Link link = factory.createPageLink(page, true);
@@ -247,7 +247,7 @@
replay();
- LinkFactory factory = new LinkFactoryImpl(request, response, map, cache, _typeCoercer, optimizer);
+ LinkFactory factory = new LinkFactoryImpl(request, response, map, cache, _typeCoercer, optimizer, null);
factory.addListener(listener);
Link link = factory.createPageLink(PAGE_LOGICAL_NAME, false);
@@ -273,7 +273,7 @@
// do the work.
expect(rootElement.triggerEvent(eq(TapestryConstants.PASSIVATE_EVENT), (Object[]) isNull(),
- isA(ComponentEventHandler.class))).andAnswer(triggerEventAnswer);
+ isA(ComponentEventCallback.class))).andAnswer(triggerEventAnswer);
listener.createdPageLink(isA(Link.class));
getMocksControl().andAnswer(createdPageLinkAnswer);
@@ -291,7 +291,7 @@
// do the work.
expect(rootElement.triggerEvent(eq(TapestryConstants.PASSIVATE_EVENT), (Object[]) isNull(),
- isA(ComponentEventHandler.class))).andAnswer(triggerEventAnswer);
+ isA(ComponentEventCallback.class))).andAnswer(triggerEventAnswer);
listener.createdActionLink(isA(Link.class));
getMocksControl().andAnswer(createdPageLinkAnswer);
@@ -319,7 +319,7 @@
@SuppressWarnings("unchecked")
public Boolean answer() throws Throwable
{
- ComponentEventHandler handler = (ComponentEventHandler) EasyMock
+ ComponentEventCallback handler = (ComponentEventCallback) EasyMock
.getCurrentArguments()[2];
handler.handleResult(new Object[]{"foo", "bar"}, null, null);
@@ -340,6 +340,7 @@
ComponentInvocationMap map = mockComponentInvocationMap();
RequestPageCache cache = mockRequestPageCache();
RequestPathOptimizer optimizer = mockRequestPathOptimizer();
+ PageRenderQueue queue = mockPageRenderQueue();
String optimizedPath = "/optimized/path";
@@ -353,6 +354,8 @@
train_getRootElement(page, rootElement);
train_triggerPassivateEventForActionLink(rootElement, listener, holder);
+ train_getRenderingPage(queue, page);
+
// This needs to be refactored a bit to be more testable.
map.store(isA(Link.class), isA(ComponentInvocation.class));
@@ -361,7 +364,7 @@
replay();
- LinkFactory factory = new LinkFactoryImpl(request, response, map, cache, _typeCoercer, optimizer);
+ LinkFactory factory = new LinkFactoryImpl(request, response, map, cache, _typeCoercer, optimizer, queue);
factory.addListener(listener);
Link link = factory.createActionLink(page, null, "myaction", false, "1.2.3", "4.5.6");
@@ -370,7 +373,55 @@
assertSame(link, holder.get());
verify();
+ }
+
+ @Test
+ public void action_for_non_active_page()
+ {
+ Request request = mockRequest();
+ Response response = mockResponse();
+ Page containingPage = mockPage();
+ Page activePage = mockPage();
+ ComponentPageElement rootElement = mockComponentPageElement();
+ LinkFactoryListener listener = mockLinkFactoryListener();
+ ComponentInvocationMap map = mockComponentInvocationMap();
+ RequestPageCache cache = mockRequestPageCache();
+ RequestPathOptimizer optimizer = mockRequestPathOptimizer();
+ PageRenderQueue queue = mockPageRenderQueue();
+
+ String optimizedPath = "/optimized/path";
+
+ final Holder<Link> holder = new Holder<Link>();
+
+ train_getLogicalName(containingPage, "MyPage");
+ train_getContextPath(request, "");
+
+ train_optimizePath(optimizer, "/mypage:myaction?t:ac=foo/bar&t:ap=activepage", optimizedPath);
+
+ train_getRootElement(activePage, rootElement);
+ train_triggerPassivateEventForActionLink(rootElement, listener, holder);
+
+ train_getRenderingPage(queue, activePage);
+
+ train_getLogicalName(activePage, "ActivePage");
+
+ // This needs to be refactored a bit to be more testable.
+
+ map.store(isA(Link.class), isA(ComponentInvocation.class));
+
+ train_encodeURL(response, "/optimized/path", ENCODED);
+
+ replay();
+
+ LinkFactory factory = new LinkFactoryImpl(request, response, map, cache, _typeCoercer, optimizer, queue);
+ factory.addListener(listener);
+
+ Link link = factory.createActionLink(containingPage, null, "myaction", false);
+
+ assertEquals(link.toURI(), ENCODED);
+ assertSame(link, holder.get());
+ verify();
}
@@ -386,6 +437,7 @@
ComponentInvocationMap map = mockComponentInvocationMap();
RequestPageCache cache = mockRequestPageCache();
RequestPathOptimizer optimizer = mockRequestPathOptimizer();
+ PageRenderQueue queue = mockPageRenderQueue();
String optimizedPath = "/optimized/path";
@@ -401,6 +453,8 @@
train_getRootElement(page, rootElement);
train_triggerPassivateEventForActionLink(rootElement, listener, holder);
+ train_getRenderingPage(queue, page);
+
// This needs to be refactored a bit to be more testable.
map.store(isA(Link.class), isA(ComponentInvocationImpl.class));
@@ -409,7 +463,7 @@
replay();
- LinkFactory factory = new LinkFactoryImpl(request, response, map, cache, _typeCoercer, optimizer);
+ LinkFactory factory = new LinkFactoryImpl(request, response, map, cache, _typeCoercer, optimizer, queue);
factory.addListener(listener);
Link link = factory.createActionLink(page, nestedId, eventName, false, context);
@@ -419,4 +473,5 @@
verify();
}
+
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ObjectComponentEventResultProcessorTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ObjectComponentEventResultProcessorTest.java?rev=612337&r1=612336&r2=612337&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ObjectComponentEventResultProcessorTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ObjectComponentEventResultProcessorTest.java Tue Jan 15 18:33:09 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.
@@ -46,7 +46,7 @@
try
{
- p.processComponentEvent(result, component, "foo.component.Gnop.blip()");
+ p.processResultValue(result, component, "foo.component.Gnop.blip()");
unreachable();
}
catch (TapestryException ex)