You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by fr...@apache.org on 2006/12/20 08:55:19 UTC

svn commit: r488946 - in /tapestry/tapestry5/tapestry-core/trunk/src: main/java/org/apache/tapestry/corelib/base/ main/java/org/apache/tapestry/corelib/components/ main/java/org/apache/tapestry/internal/ main/java/org/apache/tapestry/internal/services/...

Author: freemant
Date: Tue Dec 19 23:55:17 2006
New Revision: 488946

URL: http://svn.apache.org/viewvc?view=rev&rev=488946
Log:
1) Moved parameters from LinkImpl into InAppInvocation.
2) Moved context path from InAppInvocationPathSource into LinkImpl, thus eliminating the need for the former and PathSource.
3) Added InvocationTarget so that an InAppInvocation has an InvocationTarget instead of using subclasses.
4) Moved ValidationMessages.properties from src/main/java into src/main/resources.

Added:
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ActionLinkTarget.java
      - copied, changed from r488538, tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ActionLinkInvocation.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/InvocationTarget.java   (with props)
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/OpaqueConstantTarget.java
      - copied, changed from r488537, tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ConstantPathSource.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageLinkTarget.java
      - copied, changed from r488538, tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageLinkInvocation.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/internal/ValidationMessages.properties
      - copied unchanged from r488941, tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ValidationMessages.properties
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/InAppInvocationTest.java   (with props)
Removed:
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ValidationMessages.properties
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ActionLinkInvocation.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ConstantPathSource.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/InAppInvocationPathSource.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageLinkInvocation.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PathSource.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/LinkClicker.java
Modified:
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/base/AbstractField.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/ActionLink.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Form.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ActionLinkHandler.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ActionLinkHandlerImpl.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ComponentEventDispatcher.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/InAppInvocation.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/LinkFactoryImpl.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/LinkImpl.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageLinkHandler.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageLinkHandlerImpl.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageRenderDispatcher.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/ActionLinkInvoker.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/PageLinkInvoker.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/PageTester.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/LinkImplTest.java

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/base/AbstractField.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/base/AbstractField.java?view=diff&rev=488946&r1=488945&r2=488946
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/base/AbstractField.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/base/AbstractField.java Tue Dec 19 23:55:17 2006
@@ -156,8 +156,8 @@
      * @param paramLookup
      *            an object providing lookup access to form parameters, presumably so that the
      *            component may extract a quert parameter value that matches the component's element
-     *            name. Usually this object is the current request but could be a mocked object if
-     *            the app is driven by a {@link org.apache.tapestry.test.pagelevel.PageTester}.
+     *            name. Usually this object is the current request but could be a mock object if the
+     *            app is driven by a {@link org.apache.tapestry.test.pagelevel.PageTester}.
      * @param elementName
      *            the name of the element (used to find the correct parameter in the request)
      */

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/ActionLink.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/ActionLink.java?view=diff&rev=488946&r1=488945&r2=488946
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/ActionLink.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/ActionLink.java Tue Dec 19 23:55:17 2006
@@ -31,7 +31,6 @@
 import org.apache.tapestry.corelib.mixins.RenderInformals;
 import org.apache.tapestry.dom.Element;
 import org.apache.tapestry.internal.services.InAppInvocationMap;
-import org.apache.tapestry.internal.services.InAppInvocationPathSource;
 import org.apache.tapestry.internal.services.LinkImpl;
 import org.apache.tapestry.services.PageRenderSupport;
 
@@ -74,9 +73,8 @@
         Element element = writer.element("a", "href", link.toURI(), "id", clientId);
 
         // Allow the PageTester to extract the invocation object to invoke it later.
-        _invocationMap.put(element, ((InAppInvocationPathSource) ((LinkImpl) link).getPathSource())
-                .getInvocation());
-        
+        _invocationMap.put(element, ((LinkImpl) link).getInvocation());
+
         // TODO: Support for informal parameters, etc.
     }
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Form.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Form.java?view=diff&rev=488946&r1=488945&r2=488946
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Form.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Form.java Tue Dec 19 23:55:17 2006
@@ -38,7 +38,6 @@
 import org.apache.tapestry.dom.Element;
 import org.apache.tapestry.internal.services.FormParameterLookup;
 import org.apache.tapestry.internal.services.InAppInvocationMap;
-import org.apache.tapestry.internal.services.InAppInvocationPathSource;
 import org.apache.tapestry.internal.services.LinkImpl;
 import org.apache.tapestry.internal.util.Base64ObjectInputStream;
 import org.apache.tapestry.internal.util.Base64ObjectOutputStream;
@@ -153,15 +152,23 @@
 
         String name = _pageRenderSupport.allocateClientId(_resources.getId());
 
-        Link link = _resources.createActionLink(TapestryConstants.DEFAULT_EVENT, true, contextArray);
+        Link link = _resources
+                .createActionLink(TapestryConstants.DEFAULT_EVENT, true, contextArray);
 
-        Element element = writer.element("form", "name", name, "id", name, "method", "post", "action", link
-                .toFormURI());
+        Element element = writer.element(
+                "form",
+                "name",
+                name,
+                "id",
+                name,
+                "method",
+                "post",
+                "action",
+                link.toFormURI());
 
         // Allow the PageTester to extract the invocation object to invoke it later.
-        _invocationMap.put(element, ((InAppInvocationPathSource) ((LinkImpl) link).getPathSource())
-                .getInvocation());
-        
+        _invocationMap.put(element, ((LinkImpl) link).getInvocation());
+
         // TODO: Informal parameters
 
         _div = writer.element("div", "style", "invisible");

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ActionLinkHandler.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ActionLinkHandler.java?view=diff&rev=488946&r1=488945&r2=488946
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ActionLinkHandler.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ActionLinkHandler.java Tue Dec 19 23:55:17 2006
@@ -1,22 +1,22 @@
-// Copyright 2006 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.
-
+// Copyright 2006 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.services;
 
 import org.apache.tapestry.Link;
 
 public interface ActionLinkHandler
 {
-    Link handle(ActionLinkInvocation invocation);
+    Link handle(InAppInvocation invocation);
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ActionLinkHandlerImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ActionLinkHandlerImpl.java?view=diff&rev=488946&r1=488945&r2=488946
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ActionLinkHandlerImpl.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ActionLinkHandlerImpl.java Tue Dec 19 23:55:17 2006
@@ -12,52 +12,55 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry.internal.services;
-
-import org.apache.tapestry.ComponentEventHandler;
-import org.apache.tapestry.Link;
-import org.apache.tapestry.internal.structure.ComponentPageElement;
-import org.apache.tapestry.internal.structure.Page;
-
-public class ActionLinkHandlerImpl implements ActionLinkHandler
-{
-    private final ComponentEventHandler _componentEventHandler;
-
-    private final RequestPageCache _cache;
-
-    private final LinkFactory _linkFactory;
-
-    public ActionLinkHandlerImpl(ComponentEventHandler componentEventHandler,
-            RequestPageCache cache, LinkFactory linkFactory)
-    {
-        _componentEventHandler = componentEventHandler;
-        _cache = cache;
-        _linkFactory = linkFactory;
-    }
-
-    public Link handle(ActionLinkInvocation invocation)
-    {
-        Page page = _cache.get(invocation.getPageName());
-
-        // This is the active page, until we know better.
-
-        _cache.setActive(page);
-
-        ComponentPageElement element = page.getComponentElementByNestedId(invocation
-                .getComponentNestedId());
-
-        element.triggerEvent(
-                invocation.getAction(),
-                invocation.getContext(),
-                _componentEventHandler);
-
-        // It's possible that the component event will have changed the active page.
-        // Whatever the active page is NOW is what we'll send back (as a client redirect)
-        // to render.
-
-        page = _cache.getActive();
-
-        return _linkFactory.createPageLink(page);
-    }
-
-}
+package org.apache.tapestry.internal.services;
+
+import org.apache.tapestry.ComponentEventHandler;
+import org.apache.tapestry.Link;
+import org.apache.tapestry.internal.structure.ComponentPageElement;
+import org.apache.tapestry.internal.structure.Page;
+import org.apache.tapestry.ioc.internal.util.Defense;
+
+public class ActionLinkHandlerImpl implements ActionLinkHandler
+{
+    private final ComponentEventHandler _componentEventHandler;
+
+    private final RequestPageCache _cache;
+
+    private final LinkFactory _linkFactory;
+
+    public ActionLinkHandlerImpl(ComponentEventHandler componentEventHandler,
+            RequestPageCache cache, LinkFactory linkFactory)
+    {
+        _componentEventHandler = componentEventHandler;
+        _cache = cache;
+        _linkFactory = linkFactory;
+    }
+
+    public Link handle(InAppInvocation invocation)
+    {
+        InvocationTarget target = invocation.getTarget();
+        ActionLinkTarget actionLinkTarget = Defense.cast(target, ActionLinkTarget.class, "target");
+        Page page = _cache.get(actionLinkTarget.getPageName());
+
+        // This is the active page, until we know better.
+
+        _cache.setActive(page);
+
+        ComponentPageElement element = page.getComponentElementByNestedId(actionLinkTarget
+                .getComponentNestedId());
+
+        element.triggerEvent(
+                actionLinkTarget.getAction(),
+                invocation.getContext(),
+                _componentEventHandler);
+
+        // It's possible that the component event will have changed the active page.
+        // Whatever the active page is NOW is what we'll send back (as a client redirect)
+        // to render.
+
+        page = _cache.getActive();
+
+        return _linkFactory.createPageLink(page);
+    }
+
+}

Copied: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ActionLinkTarget.java (from r488538, tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ActionLinkInvocation.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ActionLinkTarget.java?view=diff&rev=488946&p1=tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ActionLinkInvocation.java&r1=488538&p2=tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ActionLinkTarget.java&r2=488946
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ActionLinkInvocation.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ActionLinkTarget.java Tue Dec 19 23:55:17 2006
@@ -15,13 +15,9 @@
 package org.apache.tapestry.internal.services;
 
 /**
- * It represents an in-app invocation for a page link. It is passed to an
- * {@link org.apache.tapestry.internal.services.PageLinkHandler} by both the
- * {@link org.apache.tapestry.test.pagelevel.PageTester} and the real Tapestry code
- * {@link org.apache.tapestry.internal.services.PageRenderDispatcher} in order to invoke an action *
- * link.
+ * It represents an invocation target for an action link.
  */
-public class ActionLinkInvocation extends InAppInvocation
+public class ActionLinkTarget implements InvocationTarget
 {
     private final String _action;
 
@@ -29,18 +25,15 @@
 
     private final String _componentNestedId;
 
-    public ActionLinkInvocation(String action, String pageName, String componentNestedId,
-            Object[] context)
+    public ActionLinkTarget(String action, String pageName, String componentNestedId)
     {
-        super(context);
         _action = action;
         _pageName = pageName;
         _componentNestedId = componentNestedId;
 
     }
 
-    @Override
-    public String getTargetPath()
+    public String getPath()
     {
         StringBuilder builder = new StringBuilder();
         builder.append(_pageName);

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ComponentEventDispatcher.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ComponentEventDispatcher.java?view=diff&rev=488946&r1=488945&r2=488946
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ComponentEventDispatcher.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ComponentEventDispatcher.java Tue Dec 19 23:55:17 2006
@@ -61,8 +61,8 @@
         for (int i = 1; i < chunks.length; i++)
             context[i - 1] = chunks[i];
 
-        Link link = _actionLinkHandler.handle(new ActionLinkInvocation(eventType, logicalPageName,
-                nestedComponentId, context));
+        Link link = _actionLinkHandler.handle(new InAppInvocation(new ActionLinkTarget(eventType,
+                logicalPageName, nestedComponentId), context));
 
         String URL = link.toRedirectURI();
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/InAppInvocation.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/InAppInvocation.java?view=diff&rev=488946&r1=488945&r2=488946
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/InAppInvocation.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/InAppInvocation.java Tue Dec 19 23:55:17 2006
@@ -1,45 +1,98 @@
-// Copyright 2006 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.
-
+// Copyright 2006 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.services;
 
+import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newMap;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.codec.EncoderException;
+import org.apache.commons.codec.net.URLCodec;
+import org.apache.tapestry.ioc.internal.util.InternalUtils;
+
 /**
  * It represents an invocation for a page or a component within the current app. Each invocation may
- * provide a context (Object[]) to the invocation target.
+ * provide a context (Object[]) and parameters to the invocation target.
  */
-public abstract class InAppInvocation
+public class InAppInvocation
 {
     private final Object[] _context;
 
-    public InAppInvocation(Object[] context)
+    private Map<String, String> _parameters;
+
+    private InvocationTarget _target;
+
+    public InAppInvocation(InvocationTarget target, Object[] context)
     {
+        _target = target;
         _context = context;
     }
 
     /**
-     * @see #getPath()
+     * @return A path taking the format <em>target-path</em>/e1/e2?&q1=v1&q2=v2. where the
+     *         <em>target-path</em> is the path provided by the invocation target; e1 and e2 are
+     *         elements of the context; q1 and q2 are the parameters.
      */
-    public abstract String getTargetPath();
+    public String buildURI(boolean isForm)
+    {
+        String path = getPath();
+        if (isForm || _parameters == null)
+            return path;
+
+        StringBuilder builder = new StringBuilder();
+
+        builder.append(path);
+
+        try
+        {
+            URLCodec codec = new URLCodec();
+
+            String sep = "?";
+
+            for (String name : getParameterNames())
+            {
+                String value = _parameters.get(name);
+
+                builder.append(sep);
+
+                // TODO: encode the parameter name?
+
+                builder.append(name);
+                builder.append("=");
+                builder.append(codec.encode(value));
+
+                sep = "&";
+            }
+        }
+        catch (EncoderException ex)
+        {
+            throw new RuntimeException(ex);
+        }
+
+        return builder.toString();
+    }
 
     /**
-     * @return A path taking the format <em>target-path</em>/context-element1/context-element2.
-     *         where the <em>target-path</em> is provided by the subclass.
+     * @return Just like the return value of {@link #buildURI(boolean)} except that parameters are
+     *         not included.
      */
-    public String getPath()
+    private String getPath()
     {
         StringBuilder builder = new StringBuilder();
-        builder.append(getTargetPath());
+        builder.append(_target.getPath());
 
         for (Object id : _context)
         {
@@ -57,4 +110,31 @@
         return _context;
     }
 
+    public void addParameter(String parameterName, String value)
+    {
+        if (_parameters == null)
+            _parameters = newMap();
+
+        if (_parameters.containsKey(parameterName))
+            throw new IllegalArgumentException(ServicesMessages.parameterNameMustBeUnique(
+                    parameterName,
+                    _parameters.get(parameterName)));
+
+        _parameters.put(parameterName, value);
+    }
+
+    public List<String> getParameterNames()
+    {
+        return InternalUtils.sortedKeys(_parameters);
+    }
+
+    public String getParameterValue(String name)
+    {
+        return InternalUtils.get(_parameters, name);
+    }
+
+    public InvocationTarget getTarget()
+    {
+        return _target;
+    }
 }

Added: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/InvocationTarget.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/InvocationTarget.java?view=auto&rev=488946
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/InvocationTarget.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/InvocationTarget.java Tue Dec 19 23:55:17 2006
@@ -0,0 +1,29 @@
+// Copyright 2006 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.services;
+
+/**
+ * It represents target for an in-app invocation. For example, it may be a page or an action for a
+ * component within a page.
+ */
+public interface InvocationTarget
+{
+
+    /**
+     * @see InAppInvocation#getPath()
+     */
+    String getPath();
+
+}

Propchange: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/InvocationTarget.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/LinkFactoryImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/LinkFactoryImpl.java?view=diff&rev=488946&r1=488945&r2=488946
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/LinkFactoryImpl.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/LinkFactoryImpl.java Tue Dec 19 23:55:17 2006
@@ -104,12 +104,11 @@
 
         String logicalPageName = _componentClassResolver.resolvePageClassNameToPageName(pageName);
 
-        ActionLinkInvocation invocation = new ActionLinkInvocation(action, logicalPageName,
-                component.getNestedId(), context);
-        InAppInvocationPathSource pathSource = new InAppInvocationPathSource(_contextPathSource
-                .getContextPath(), invocation);
+        ActionLinkTarget target = new ActionLinkTarget(action, logicalPageName, component
+                .getNestedId());
+        InAppInvocation invocation = new InAppInvocation(target, context);
 
-        Link link = new LinkImpl(_encoder, pathSource);
+        Link link = new LinkImpl(_encoder, _contextPathSource.getContextPath(), invocation);
 
         for (LinkFactoryListener listener : _listeners)
             listener.createdActionLink(link);
@@ -144,11 +143,10 @@
 
         rootElement.triggerEvent(TapestryConstants.PASSIVATE_EVENT, null, handler);
 
-        PageLinkInvocation invocation = new PageLinkInvocation(logicalPageName, context.toArray());
-        InAppInvocationPathSource pathSource = new InAppInvocationPathSource(_contextPathSource
-                .getContextPath(), invocation);
+        PageLinkTarget target = new PageLinkTarget(logicalPageName);
+        InAppInvocation invocation = new InAppInvocation(target, context.toArray());
 
-        Link link = new LinkImpl(_encoder, pathSource);
+        Link link = new LinkImpl(_encoder, _contextPathSource.getContextPath(), invocation);
 
         for (LinkFactoryListener listener : _listeners)
             listener.createdPageLink(link);

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/LinkImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/LinkImpl.java?view=diff&rev=488946&r1=488945&r2=488946
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/LinkImpl.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/LinkImpl.java Tue Dec 19 23:55:17 2006
@@ -14,15 +14,9 @@
 
 package org.apache.tapestry.internal.services;
 
-import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newMap;
-
 import java.util.List;
-import java.util.Map;
 
-import org.apache.commons.codec.EncoderException;
-import org.apache.commons.codec.net.URLCodec;
 import org.apache.tapestry.Link;
-import org.apache.tapestry.ioc.internal.util.InternalUtils;
 
 /**
  * Starting implementation of {@link Link}. Currently does not support query parameters.
@@ -31,101 +25,64 @@
 {
     private final URLEncoder _encoder;
 
-    private final PathSource _pathSource;
+    private final String _contextPath;
 
-    private Map<String, String> _parameters;
+    private final InAppInvocation _invocation;
 
-    public LinkImpl(URLEncoder encoder, String path)
+    public LinkImpl(URLEncoder encoder, String contextPath, String targetPath)
     {
-        _encoder = encoder;
-        _pathSource = new ConstantPathSource(path);
+        this(encoder, contextPath, new InAppInvocation(new OpaqueConstantTarget(targetPath),
+                new Object[0]));
     }
 
-    public LinkImpl(URLEncoder encoder, PathSource pathSource)
+    public LinkImpl(URLEncoder encoder, String contextPath, InAppInvocation invocation)
     {
+        _contextPath = contextPath;
         _encoder = encoder;
-        _pathSource = pathSource;
+        _invocation = invocation;
     }
 
     public void addParameter(String parameterName, String value)
     {
-        if (_parameters == null)
-            _parameters = newMap();
-
-        if (_parameters.containsKey(parameterName))
-            throw new IllegalArgumentException(ServicesMessages.parameterNameMustBeUnique(
-                    parameterName,
-                    _parameters.get(parameterName)));
-
-        _parameters.put(parameterName, value);
+        _invocation.addParameter(parameterName, value);
     }
 
     public String toFormURI()
     {
-        return _encoder.encodeURL(_pathSource.getPath());
+        return _encoder.encodeURL(buildURI(true));
     }
 
     public List<String> getParameterNames()
     {
-        return InternalUtils.sortedKeys(_parameters);
+        return _invocation.getParameterNames();
     }
 
     public String getParameterValue(String name)
     {
-        return InternalUtils.get(_parameters, name);
+        return _invocation.getParameterValue(name);
     }
 
     public String toURI()
     {
-        return _encoder.encodeURL(buildURI());
+        return _encoder.encodeURL(buildURI(false));
     }
 
-    private String buildURI()
+    private String buildURI(boolean isForm)
     {
-        String path = _pathSource.getPath();
-        if (_parameters == null)
-            return path;
-
         StringBuilder builder = new StringBuilder();
-
-        builder.append(path);
-
-        try
-        {
-            URLCodec codec = new URLCodec();
-
-            String sep = "?";
-
-            for (String name : getParameterNames())
-            {
-                String value = _parameters.get(name);
-
-                builder.append(sep);
-
-                // TODO: encode the parameter name?
-
-                builder.append(name);
-                builder.append("=");
-                builder.append(codec.encode(value));
-
-                sep = "&";
-            }
-        }
-        catch (EncoderException ex)
-        {
-            throw new RuntimeException(ex);
-        }
-
+        builder.append(_contextPath);
+        builder.append("/");
+        builder.append(_invocation.buildURI(isForm));
         return builder.toString();
     }
 
     public String toRedirectURI()
     {
-        return _encoder.encodeRedirectURL(buildURI());
+        return _encoder.encodeRedirectURL(buildURI(false));
     }
 
-    public PathSource getPathSource()
+    public InAppInvocation getInvocation()
     {
-        return _pathSource;
+        return _invocation;
     }
 }

Copied: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/OpaqueConstantTarget.java (from r488537, tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ConstantPathSource.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/OpaqueConstantTarget.java?view=diff&rev=488946&p1=tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ConstantPathSource.java&r1=488537&p2=tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/OpaqueConstantTarget.java&r2=488946
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ConstantPathSource.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/OpaqueConstantTarget.java Tue Dec 19 23:55:17 2006
@@ -12,20 +12,23 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry.internal.services;
-
-public class ConstantPathSource implements PathSource
-{
-    private String _path;
-
-    public ConstantPathSource(String path)
-    {
-        this._path = path;
-    }
-
-    public String getPath()
-    {
-        return _path;
-    }
-
-}
+package org.apache.tapestry.internal.services;
+
+/**
+ * An invocation target that is specified as a path without further meaning.
+ */
+public class OpaqueConstantTarget implements InvocationTarget
+{
+    private String _path;
+
+    public OpaqueConstantTarget(String path)
+    {
+        this._path = path;
+    }
+
+    public String getPath()
+    {
+        return _path;
+    }
+
+}

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageLinkHandler.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageLinkHandler.java?view=diff&rev=488946&r1=488945&r2=488946
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageLinkHandler.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageLinkHandler.java Tue Dec 19 23:55:17 2006
@@ -1,20 +1,20 @@
-// Copyright 2006 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.
-
+// Copyright 2006 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.services;
 
 public interface PageLinkHandler
 {
-    void handle(PageLinkInvocation invocation, PageRenderer renderer);
+    void handle(InAppInvocation invocation, PageRenderer renderer);
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageLinkHandlerImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageLinkHandlerImpl.java?view=diff&rev=488946&r1=488945&r2=488946
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageLinkHandlerImpl.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageLinkHandlerImpl.java Tue Dec 19 23:55:17 2006
@@ -16,6 +16,7 @@
 
 import org.apache.tapestry.TapestryConstants;
 import org.apache.tapestry.internal.structure.Page;
+import org.apache.tapestry.ioc.internal.util.Defense;
 
 /**
  * Handles a PageLink as specified by a PageLinkPathSource by activating and then rendering the
@@ -30,9 +31,11 @@
         _cache = cache;
     }
 
-    public void handle(PageLinkInvocation invocation, PageRenderer renderer)
+    public void handle(InAppInvocation invocation, PageRenderer renderer)
     {
-        Page page = _cache.get(invocation.getPageName());
+        InvocationTarget target = invocation.getTarget();
+        PageLinkTarget pageLinkTarget = Defense.cast(target, PageLinkTarget.class, "target");
+        Page page = _cache.get(pageLinkTarget.getPageName());
         // Fire a notification so that the page can set itself up for the given context
 
         page.getRootElement().triggerEvent(

Copied: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageLinkTarget.java (from r488538, tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageLinkInvocation.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageLinkTarget.java?view=diff&rev=488946&p1=tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageLinkInvocation.java&r1=488538&p2=tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageLinkTarget.java&r2=488946
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageLinkInvocation.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageLinkTarget.java Tue Dec 19 23:55:17 2006
@@ -14,27 +14,26 @@
 
 package org.apache.tapestry.internal.services;
 
+
 /**
- * It represents an in-app invocation for a page link. It is passed to an
+ * It represents an in-app invocation target for a page link. It is passed to an
  * {@link org.apache.tapestry.internal.services.ActionLinkHandler} by both the
  * {@link org.apache.tapestry.test.pagelevel.PageTester} and the real Tapestry code
  * {@link org.apache.tapestry.internal.services.PageRenderDispatcher} in order to invoke a page
  * link.
  */
-public class PageLinkInvocation extends InAppInvocation
+public class PageLinkTarget implements InvocationTarget
 {
 
     private final String _pageName;
 
-    public PageLinkInvocation(String pageName, Object[] context)
+    public PageLinkTarget(String pageName)
     {
-        super(context);
         _pageName = pageName;
 
     }
 
-    @Override
-    public String getTargetPath()
+    public String getPath()
     {
         StringBuilder builder = new StringBuilder();
         builder.append(_pageName);

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageRenderDispatcher.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageRenderDispatcher.java?view=diff&rev=488946&r1=488945&r2=488946
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageRenderDispatcher.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageRenderDispatcher.java Tue Dec 19 23:55:17 2006
@@ -64,22 +64,24 @@
             // TODO: Decode strings?
             context[i - 1] = terms[i];
         }
-        _handler.handle(new PageLinkInvocation(logicalPageName, context), new PageRenderer()
-        {
-
-            public void renderPage(Page page)
-            {
-                try
-                {
-                    _renderer.renderPageResponse(page, response);
-                }
-                catch (IOException ex)
+        _handler.handle(
+                new InAppInvocation(new PageLinkTarget(logicalPageName), context),
+                new PageRenderer()
                 {
-                    new RuntimeException(ex);
-                }
 
-            }
-        });
+                    public void renderPage(Page page)
+                    {
+                        try
+                        {
+                            _renderer.renderPageResponse(page, response);
+                        }
+                        catch (IOException ex)
+                        {
+                            new RuntimeException(ex);
+                        }
+
+                    }
+                });
 
         return true;
     }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/ActionLinkInvoker.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/ActionLinkInvoker.java?view=diff&rev=488946&r1=488945&r2=488946
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/ActionLinkInvoker.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/ActionLinkInvoker.java Tue Dec 19 23:55:17 2006
@@ -1,25 +1,23 @@
-// Copyright 2006 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.
-
+// Copyright 2006 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.test.pagelevel;
 
 import org.apache.tapestry.Link;
 import org.apache.tapestry.dom.Document;
 import org.apache.tapestry.internal.services.ActionLinkHandler;
-import org.apache.tapestry.internal.services.ActionLinkInvocation;
 import org.apache.tapestry.internal.services.InAppInvocation;
-import org.apache.tapestry.internal.services.InAppInvocationPathSource;
 import org.apache.tapestry.internal.services.LinkImpl;
 import org.apache.tapestry.ioc.Registry;
 
@@ -51,12 +49,11 @@
      */
     public Document invoke(InAppInvocation invocation)
     {
-        Link followupLink = click((ActionLinkInvocation) invocation);
-        return _followupInvoker.invoke(((InAppInvocationPathSource) ((LinkImpl) followupLink)
-                .getPathSource()).getInvocation());
+        Link followupLink = click(invocation);
+        return _followupInvoker.invoke(((LinkImpl) followupLink).getInvocation());
     }
 
-    private Link click(ActionLinkInvocation invocation)
+    private Link click(InAppInvocation invocation)
     {
         try
         {

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/PageLinkInvoker.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/PageLinkInvoker.java?view=diff&rev=488946&r1=488945&r2=488946
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/PageLinkInvoker.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/PageLinkInvoker.java Tue Dec 19 23:55:17 2006
@@ -1,24 +1,23 @@
-// Copyright 2006 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.
-
+// Copyright 2006 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.test.pagelevel;
 
 import org.apache.tapestry.dom.Document;
 import org.apache.tapestry.internal.services.InAppInvocation;
 import org.apache.tapestry.internal.services.MarkupWriterImpl;
 import org.apache.tapestry.internal.services.PageLinkHandler;
-import org.apache.tapestry.internal.services.PageLinkInvocation;
 import org.apache.tapestry.internal.services.PageMarkupRenderer;
 import org.apache.tapestry.internal.services.PageRenderer;
 import org.apache.tapestry.internal.structure.Page;
@@ -54,7 +53,7 @@
         try
         {
             final MarkupWriterImpl writer = new MarkupWriterImpl();
-            _pageLinkHandler.handle((PageLinkInvocation) invocation, new PageRenderer()
+            _pageLinkHandler.handle(invocation, new PageRenderer()
             {
 
                 public void renderPage(Page page)

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/PageTester.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/PageTester.java?view=diff&rev=488946&r1=488945&r2=488946
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/PageTester.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/PageTester.java Tue Dec 19 23:55:17 2006
@@ -23,9 +23,9 @@
 import org.apache.tapestry.dom.Element;
 import org.apache.tapestry.dom.Node;
 import org.apache.tapestry.internal.TapestryAppInitializer;
-import org.apache.tapestry.internal.services.ActionLinkInvocation;
+import org.apache.tapestry.internal.services.ActionLinkTarget;
 import org.apache.tapestry.internal.services.InAppInvocation;
-import org.apache.tapestry.internal.services.PageLinkInvocation;
+import org.apache.tapestry.internal.services.PageLinkTarget;
 import org.apache.tapestry.ioc.Registry;
 import org.apache.tapestry.ioc.internal.util.Defense;
 import org.apache.tapestry.ioc.util.StrategyRegistry;
@@ -81,8 +81,8 @@
     private void buildInvokersRegistry()
     {
         Map<Class, InAppInvoker> map = newMap();
-        map.put(PageLinkInvocation.class, new PageLinkInvoker(_registry));
-        map.put(ActionLinkInvocation.class, new ActionLinkInvoker(_registry, this));
+        map.put(PageLinkTarget.class, new PageLinkInvoker(_registry));
+        map.put(ActionLinkTarget.class, new ActionLinkInvoker(_registry, this));
         _invokerRegistry = new StrategyRegistry<InAppInvoker>(InAppInvoker.class, map);
     }
 
@@ -137,7 +137,7 @@
      */
     public Document renderPage(String pageName)
     {
-        return invoke(new PageLinkInvocation(pageName, new Object[0]));
+        return invoke(new InAppInvocation(new PageLinkTarget(pageName), new Object[0]));
     }
 
     /**
@@ -170,7 +170,7 @@
         // It is critical to clear the map before invoking an invocation (render a page or click a
         // link).
         _invocationMap.clear();
-        InAppInvoker invoker = _invokerRegistry.getByInstance(invocation);
+        InAppInvoker invoker = _invokerRegistry.getByInstance(invocation.getTarget());
         return invoker.invoke(invocation);
     }
 

Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/InAppInvocationTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/InAppInvocationTest.java?view=auto&rev=488946
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/InAppInvocationTest.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/InAppInvocationTest.java Tue Dec 19 23:55:17 2006
@@ -0,0 +1,52 @@
+// Copyright 2006 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.services;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public class InAppInvocationTest extends Assert
+{
+    @Test
+    public void no_context()
+    {
+        InAppInvocation invocation = new InAppInvocation(new OpaqueConstantTarget("abc"),
+                new Object[0]);
+        assertEquals(invocation.buildURI(false), "abc");
+        assertEquals(invocation.buildURI(true), "abc");
+    }
+
+    @Test
+    public void context()
+    {
+        InAppInvocation invocation = new InAppInvocation(new OpaqueConstantTarget("abc"),
+                new Object[]
+                { "x", 123 });
+        assertEquals(invocation.buildURI(false), "abc/x/123");
+        assertEquals(invocation.buildURI(true), "abc/x/123");
+    }
+
+    @Test
+    public void parameters()
+    {
+        InAppInvocation invocation = new InAppInvocation(new OpaqueConstantTarget("abc"),
+                new Object[]
+                { "x", 123 });
+        invocation.addParameter("p1", "foo");
+        invocation.addParameter("p2", "bar");
+        assertEquals(invocation.buildURI(false), "abc/x/123?p1=foo&p2=bar");
+        assertEquals(invocation.buildURI(true), "abc/x/123");
+    }
+}

Propchange: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/InAppInvocationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/LinkImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/LinkImplTest.java?view=diff&rev=488946&r1=488945&r2=488946
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/LinkImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/LinkImplTest.java Tue Dec 19 23:55:17 2006
@@ -34,7 +34,7 @@
 
         replay();
 
-        Link link = new LinkImpl(response, "/foo/bar");
+        Link link = new LinkImpl(response, "/foo", "bar");
 
         link.addParameter("fred", "flintstone");
         link.addParameter("barney", "rubble");
@@ -51,7 +51,7 @@
 
         replay();
 
-        Link link = new LinkImpl(response, "/foo/bar");
+        Link link = new LinkImpl(response, "/foo", "bar");
 
         link.addParameter("fred", "flintstone");
         link.addParameter("barney", "rubble");
@@ -72,7 +72,7 @@
 
         replay();
 
-        Link link = new LinkImpl(response, "/foo/bar");
+        Link link = new LinkImpl(response, "/foo", "bar");
 
         link.addParameter("fred", "flint stone?");
 
@@ -88,7 +88,7 @@
 
         replay();
 
-        Link link = new LinkImpl(response, "/foo/bar");
+        Link link = new LinkImpl(response, "/foo", "bar");
 
         link.addParameter("fred", "flintstone");
         link.addParameter("barney", "rubble");
@@ -105,7 +105,7 @@
 
         replay();
 
-        Link link = new LinkImpl(response, "/foo/bar");
+        Link link = new LinkImpl(response, "/foo", "bar");
 
         link.addParameter("fred", "flintstone");
         try
@@ -132,7 +132,7 @@
 
         replay();
 
-        Link link = new LinkImpl(response, "/foo/bar");
+        Link link = new LinkImpl(response, "/foo", "bar");
 
         link.addParameter("fred", "flintstone");
         link.addParameter("barney", "rubble");