You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by jk...@apache.org on 2006/07/25 00:53:26 UTC
svn commit: r425213 - in /tapestry/tapestry4/trunk:
tapestry-examples/TimeTracker/
tapestry-framework/src/java/org/apache/tapestry/
tapestry-framework/src/java/org/apache/tapestry/engine/
tapestry-framework/src/test/org/apache/tapestry/engine/
Author: jkuhnert
Date: Mon Jul 24 15:53:25 2006
New Revision: 425213
URL: http://svn.apache.org/viewvc?rev=425213&view=rev
Log:
Added new activate(IPage page, boolean validate) method to RequestCycle so that the
ExternalService can control the order of when activateExternalLink / validate happen
on the page. Also updated TimeTracker pom to use new correct jetty launcher version.
Added:
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/ExternalLinkPage.java
Modified:
tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/pom.xml
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/IRequestCycle.java
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/engine/ExternalService.java
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/engine/RequestCycle.java
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/ExternalServiceTest.java
Modified: tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/pom.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/pom.xml?rev=425213&r1=425212&r2=425213&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/pom.xml (original)
+++ tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/pom.xml Mon Jul 24 15:53:25 2006
@@ -88,7 +88,7 @@
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty6-plugin</artifactId>
- <version>6.0-SNAPSHOT</version>
+ <version>6.0.0beta17</version>
<configuration>
<webAppSourceDirectory>${basedir}/src/context</webAppSourceDirectory>
<scanIntervalSeconds>10</scanIntervalSeconds>
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/IRequestCycle.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/IRequestCycle.java?rev=425213&r1=425212&r2=425213&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/IRequestCycle.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/IRequestCycle.java Mon Jul 24 15:53:25 2006
@@ -244,6 +244,21 @@
void activate(IPage page);
/**
+ * Same behaviour as {@link #activate(IPage)}, except the page is/isn't validated based on the passed
+ * in boolean. The default behaviour of page activation is that the activated page <i>is</i> validate.
+ *
+ * <p>
+ * This is currenty implemented to support activating externally linked pages by the ExternalService.
+ * </p>
+ *
+ * @param page
+ * The page to activate.
+ * @param validate
+ * Whether or not to validate the page in addition to activating it.
+ */
+ void activate(IPage page, boolean validate);
+
+ /**
* Returns a query parameter value, or null if not provided in the request. If multiple values
* are provided, returns the first value.
*
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/engine/ExternalService.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/engine/ExternalService.java?rev=425213&r1=425212&r2=425213&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/engine/ExternalService.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/engine/ExternalService.java Mon Jul 24 15:53:25 2006
@@ -160,10 +160,18 @@
cycle.setListenerParameters(parameters);
- cycle.activate(page);
+ cycle.activate(page, false);
page.activateExternalPage(parameters, cycle);
+
+ // perform page validation ~after~ external link activation
+
+ Tapestry.clearMethodInvocations();
+ page.validate(cycle);
+
+ Tapestry.checkMethodInvocation(Tapestry.ABSTRACTPAGE_VALIDATE_METHOD_ID, "validate()", page);
+
_responseRenderer.renderResponse(cycle);
}
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/engine/RequestCycle.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/engine/RequestCycle.java?rev=425213&r1=425212&r2=425213&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/engine/RequestCycle.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/engine/RequestCycle.java Mon Jul 24 15:53:25 2006
@@ -505,20 +505,30 @@
public void activate(IPage page)
{
+ activate(page, true);
+ }
+
+ /** @since 4.1 */
+
+ public void activate(IPage page, boolean validate)
+ {
Defense.notNull(page, "page");
if (LOG.isDebugEnabled())
LOG.debug("Activating page " + page);
- Tapestry.clearMethodInvocations();
-
- page.validate(this);
-
- Tapestry.checkMethodInvocation(Tapestry.ABSTRACTPAGE_VALIDATE_METHOD_ID, "validate()", page);
-
+ if (validate) {
+
+ Tapestry.clearMethodInvocations();
+
+ page.validate(this);
+
+ Tapestry.checkMethodInvocation(Tapestry.ABSTRACTPAGE_VALIDATE_METHOD_ID, "validate()", page);
+ }
+
_page = page;
}
-
+
/** @since 4.0 */
public String getParameter(String name)
{
Added: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/ExternalLinkPage.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/ExternalLinkPage.java?rev=425213&view=auto
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/ExternalLinkPage.java (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/ExternalLinkPage.java Mon Jul 24 15:53:25 2006
@@ -0,0 +1,40 @@
+// Copyright Jul 24, 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.engine;
+
+import org.apache.tapestry.IExternalPage;
+import org.apache.tapestry.IRequestCycle;
+import org.apache.tapestry.html.BasePage;
+
+
+/**
+ * Test class used by {@link ExternalServiceTest}.
+ *
+ * @author jkuhnert
+ */
+public abstract class ExternalLinkPage extends BasePage implements IExternalPage
+{
+
+ /**
+ * {@inheritDoc}
+ */
+ public void activateExternalPage(Object[] parameters, IRequestCycle cycle)
+ {
+ }
+
+ public void validate(IRequestCycle cycle)
+ {
+ super.validate(cycle);
+ }
+}
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/ExternalServiceTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/ExternalServiceTest.java?rev=425213&r1=425212&r2=425213&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/ExternalServiceTest.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/ExternalServiceTest.java Mon Jul 24 15:53:25 2006
@@ -39,7 +39,7 @@
@Test
public class ExternalServiceTest extends ServiceTestCase
{
- public void testGetLink()
+ public void test_Get_Link()
{
Object[] serviceParameters = new Object[0];
LinkFactory lf = newLinkFactory();
@@ -63,25 +63,27 @@
verify();
}
- public void testService() throws Exception
+ public void test_Service() throws Exception
{
IRequestCycle cycle = newCycle();
- IExternalPage page = newMock(IExternalPage.class);
+ IExternalPage page = newInstance(ExternalLinkPage.class, new Object[0]);
Object[] parameters = new Object[0];
LinkFactory lf = newLinkFactory();
ResponseRenderer rr = newResponseRenderer();
-
+
trainGetParameter(cycle, ServiceConstants.PAGE, "ActivePage");
-
+
trainGetPage(cycle, "ActivePage", page);
-
+
trainExtractListenerParameters(lf, cycle, parameters);
-
+
cycle.setListenerParameters(parameters);
- cycle.activate(page);
-
+ cycle.activate(page, false);
+
page.activateExternalPage(parameters, cycle);
-
+
+ page.validate(cycle);
+
rr.renderResponse(cycle);
replay();
@@ -95,7 +97,7 @@
verify();
}
- public void testServiceWrongType() throws Exception
+ public void test_Service_Wrong_Type() throws Exception
{
IRequestCycle cycle = newCycle();