[prev in list] [next in list] [prev in thread] [next in thread]
List: tapestry-dev
Subject: svn commit: r748906 - in /tapestry/tapestry5/trunk: src/site/apt/guide/
From: hlship () apache ! org
Date: 2009-02-28 19:09:59
Message-ID: 20090228190959.EA8752388870 () eris ! apache ! org
[Download RAW message or body]
Author: hlship
Date: Sat Feb 28 19:09:57 2009
New Revision: 748906
URL: http://svn.apache.org/viewvc?rev=748906&view=rev
Log:
TAP5-544: Improve JavaScript handling to prevent the user from clicking Ajax-oriented \
links and forms before the page is "ready"
Added:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/MarkupConstants.java
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/dark-ajax-loader.gif \
(with props) tapestry/tapestry5/trunk/tapestry-core/src/test/app1/SlowAjaxDemo.tml
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/SlowAjaxDemo.java
Removed:
tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/internal/services/empty_document_with_scripts_at_bottom.txt
Modified:
tapestry/tapestry5/trunk/src/site/apt/guide/ajax.apt
tapestry/tapestry5/trunk/src/site/apt/guide/conf.apt
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractComponentEventLink.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/LinkSubmit.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DocumentLinkerImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/default.css
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/DocumentLinkerImplTest.java
tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/internal/services/add_script.txt
tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/internal/services/add_script_in_development_mode.txt
tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/internal/services/add_script_links.txt
tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/internal/services/duplicate_script_links_ignored.txt
tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/internal/services/no_body_element.txt
tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/internal/services/script_written_raw.txt
Modified: tapestry/tapestry5/trunk/src/site/apt/guide/ajax.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/src/site/apt/guide/ajax.apt?rev=748906&r1=748905&r2=748906&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/src/site/apt/guide/ajax.apt (original)
+++ tapestry/tapestry5/trunk/src/site/apt/guide/ajax.apt Sat Feb 28 19:09:57 2009
@@ -94,7 +94,10 @@
the library is needed.
Even though the dragdrop.js library is stored inside a JAR file, Tapestry ensures \
that it can
- be accessed from the client web browser.
+ be accessed from the client web browser. A Tapestry URL within the virtual folder \
"/assets" is created; + the file will be given a version number (the application \
version number if not specified more specifically) + and will be sent to the browser \
with a far-future expires header (to encourage the browser to cache the file + \
aggresively).
* addScript()
@@ -334,6 +337,25 @@
[]
+Handling Slow Page Loads
+
+ If your page loads slowly (typically, because of scripts loaded from external \
sites), you may see a race + condition where the user can click on a link before an \
event handler for that link has been wired up. +
+ The client-side function <<<Tapestry.waitForPage()>> can be used in an element's \
onclick handler to force + a wait for the page to fully load. In this race \
condition, the screen will dim and a message will appear + advising the user to \
wait a moment; once the page is fully loaded, this modal dialog will be removed. +
+ The correct usage is:
+
+----
+ <a href="..." onclick="javascript:Tapestry.waitForPage(event);"> ... </a>
+----
+
+ The constant
+ {{{../apidocs/org/apache/tapestry5/MarkupConstants.html}MarkupConstants.WAIT_FOR_PAGE}}
+ contains this snippet.
+
The Standard Tapestry Library
Tapestry's client-side support, the standard Tapestry library, is the file \
tapestry.js,
Modified: tapestry/tapestry5/trunk/src/site/apt/guide/conf.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/src/site/apt/guide/conf.apt?rev=748906&r1=748905&r2=748906&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/src/site/apt/guide/conf.apt (original)
+++ tapestry/tapestry5/trunk/src/site/apt/guide/conf.apt Sat Feb 28 19:09:57 2009
@@ -215,12 +215,6 @@
If true, then the page may only be accessed via HTTPS. The \
{{{../apidocs/org/apache/tapestry5/annotations/Secure.html}@Secure}} annotation will \
set this value to true.
- [tapestry.script-at-top]
- If true, then links for external JavaScript libraries will be placed at the top \
of the page, inside the
- \<head\> element, rather than in the default location (at the bottom of the \
\<body\> element). The \<script\> block for per-page
- initialization will be placed at the bottom of the page in either case. The \
default (scripts at the bottom)
- was chosen in accordance with \
{{{http://developer.yahoo.com/performance/rules.html#js_bottom}Yahoo Peformance Best \
Practices}}.
-
[tapestry.scriptaculous]
The path to the embedded copy of {{{http://script.aculo.us/}script.aculo.us}} \
packaged with Tapestry. This value may be overridden
to use a different version of the script.aculo.us library. Tapestry's default \
version is 1.8.1
Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/MarkupConstants.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/MarkupConstants.java?rev=748906&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/MarkupConstants.java \
(added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/MarkupConstants.java \
Sat Feb 28 19:09:57 2009 @@ -0,0 +1,38 @@
+// Copyright 2009 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry5;
+
+/**
+ * Constants used when rendering page markup.
+ *
+ * @since 5.1.0.1
+ */
+public class MarkupConstants
+{
+
+ /**
+ * Handler for the onclick event (for links) or other events (such as forms) to \
ensure the page is loaded before + * allowing the click event to occur. Refrences \
a client-side JavaScript function that displays a standard "wait for + * page to \
load" modal dialog. + */
+ public static final String WAIT_FOR_PAGE = \
"javascript:Tapestry.waitForPage(event);"; +
+ /**
+ * Name of attribute for intercepting the user clicking a link.
+ *
+ * @see #WAIT_FOR_PAGE
+ */
+ public static final String ONCLICK = "onclick";
+}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java \
/org/apache/tapestry5/SymbolConstants.java?rev=748906&r1=748905&r2=748906&view=diff \
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java \
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java \
Sat Feb 28 19:09:57 2009 @@ -96,6 +96,8 @@
* If true, then links for external JavaScript libraries are placed at the top \
of the document (just inside the
* <body> element). If false, the default, then the libraries are placed \
at the bottom of the document.
* Per-page initialization always goes at the bottom.
+ *
+ * @deprecated since 5.1.0.1; scripts are now always at the top (see TAP5-544)
*/
public static final String SCRIPTS_AT_TOP = "tapestry.script-at-top";
@@ -136,8 +138,8 @@
/**
* If "true" (the default) then GZip compression is enabled for dynamic requests \
and for static assets. If you are
- * using a server that handles GZip compression for you, or you don't want to ue \
the extra processing power necessary
- * to GZIP requests, then override this to "false".
+ * using a server that handles GZip compression for you, or you don't want to ue \
the extra processing power + * necessary to GZIP requests, then override this to \
"false".
*
* @see #MIN_GZIP_SIZE
* @since 5.1.0.0
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractComponentEventLink.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java \
/org/apache/tapestry5/corelib/base/AbstractComponentEventLink.java?rev=748906&r1=748905&r2=748906&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractComponentEventLink.java \
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractComponentEventLink.java \
Sat Feb 28 19:09:57 2009 @@ -16,6 +16,7 @@
import org.apache.tapestry5.BindingConstants;
import org.apache.tapestry5.Link;
+import org.apache.tapestry5.MarkupConstants;
import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.annotations.Environmental;
import org.apache.tapestry5.annotations.Parameter;
@@ -54,7 +55,7 @@
if (zone != null)
{
- writer.getElement().forceAttributes("href", "#");
+ writer.getElement().forceAttributes(MarkupConstants.ONCLICK, \
MarkupConstants.WAIT_FOR_PAGE);
clientBehaviorSupport.linkZone(getClientId(), zone, link);
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java \
/org/apache/tapestry5/corelib/components/Form.java?rev=748906&r1=748905&r2=748906&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java \
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java \
Sat Feb 28 19:09:57 2009 @@ -271,6 +271,9 @@
"method", "post",
"action", link);
+ if (zone != null || clientValidation)
+ writer.attributes("onsubmit", MarkupConstants.WAIT_FOR_PAGE);
+
resources.renderInformalParameters(writer);
div = writer.element("div", "class", CSSClassConstants.INVISIBLE);
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/LinkSubmit.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java \
/org/apache/tapestry5/corelib/components/LinkSubmit.java?rev=748906&r1=748905&r2=748906&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/LinkSubmit.java \
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/LinkSubmit.java \
Sat Feb 28 19:09:57 2009 @@ -1,4 +1,4 @@
-// Copyright 2008 The Apache Software Foundation
+// Copyright 2008, 2009 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.
@@ -117,7 +117,11 @@
formSupport.store(this, new ProcessSubmission(clientId));
writer.element("a",
+
"id", clientId,
+
+ MarkupConstants.ONCLICK, MarkupConstants.WAIT_FOR_PAGE,
+
"href", "#");
resources.renderInformalParameters(writer);
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DocumentLinkerImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java \
/org/apache/tapestry5/internal/services/DocumentLinkerImpl.java?rev=748906&r1=748905&r2=748906&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DocumentLinkerImpl.java \
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DocumentLinkerImpl.java \
Sat Feb 28 19:09:57 2009 @@ -34,18 +34,15 @@
private final boolean developmentMode;
- private final boolean scriptsAtTop;
-
private final boolean omitGeneratorMetaTag;
private final String tapestryBanner;
- public DocumentLinkerImpl(boolean productionMode, boolean scriptsAtTop, boolean \
omitGeneratorMetaTag, + public DocumentLinkerImpl(boolean productionMode, boolean \
omitGeneratorMetaTag, String tapestryVersion)
{
developmentMode = !productionMode;
- this.scriptsAtTop = scriptsAtTop;
this.omitGeneratorMetaTag = omitGeneratorMetaTag;
tapestryBanner = String.format("Apache Tapestry Framework (version %s)", \
tapestryVersion); @@ -115,9 +112,7 @@
if (!rootElementName.equals("html"))
throw new \
RuntimeException(ServicesMessages.documentMissingHTMLRoot(rootElementName));
- String childElement = scriptsAtTop ? "head" : "body";
-
- Element container = findOrCreateElement(root, childElement, scriptsAtTop);
+ Element container = findOrCreateElement(root, "head", true);
// TAPESTRY-2364
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java \
/org/apache/tapestry5/services/TapestryModule.java?rev=748906&r1=748905&r2=748906&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java \
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java \
Sat Feb 28 19:09:57 2009 @@ -1570,9 +1570,6 @@
@Symbol(SymbolConstants.PRODUCTION_MODE)
final boolean productionMode,
- @Symbol(SymbolConstants.SCRIPTS_AT_TOP)
- final boolean scriptsAtTop,
-
@Path("${tapestry.default-stylesheet}")
final Asset stylesheetAsset,
@@ -1595,7 +1592,7 @@
{
public void renderMarkup(MarkupWriter writer, MarkupRenderer renderer)
{
- DocumentLinkerImpl linker = new DocumentLinkerImpl(productionMode, \
scriptsAtTop, omitGeneratorMeta, + DocumentLinkerImpl linker = new \
DocumentLinkerImpl(productionMode, omitGeneratorMeta,
tapestryVersion);
environment.push(DocumentLinker.class, linker);
@@ -2013,8 +2010,6 @@
configuration.add(SymbolConstants.EXCEPTION_REPORT_PAGE, "ExceptionReport");
- configuration.add(SymbolConstants.SCRIPTS_AT_TOP, "false");
-
configuration.add(SymbolConstants.MIN_GZIP_SIZE, "100");
Random random = new Random(System.currentTimeMillis());
Added: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/dark-ajax-loader.gif
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/dark-ajax-loader.gif?rev=748906&view=auto
==============================================================================
Binary file - no diff available.
Propchange: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/dark-ajax-loader.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/default.css
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/default.css?rev=748906&r1=748905&r2=748906&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/default.css \
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/default.css \
Sat Feb 28 19:09:57 2009 @@ -476,4 +476,22 @@
font-weight: bold;
padding-right: 20px;
background: transparent url(ajax-loader.gif) no-repeat right top;
+}
+
+DIV.t-dialog-overlay {
+ position: absolute;
+ top: 0;
+ left: 0;
+ z-index: 90;
+ width: 100%;
+ background: black;
+}
+
+DIV.t-page-loading-banner {
+ float: left;
+ width: auto;
+ font-weight: bold;
+ padding-right: 20px;
+ color: white;
+ background: transparent url(dark-ajax-loader.gif) no-repeat right top;
}
\ No newline at end of file
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js?rev=748906&r1=748905&r2=748906&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js \
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js \
Sat Feb 28 19:09:57 2009 @@ -47,6 +47,56 @@
/** Time, in seconds, that console messages are visible. */
CONSOLE_DURATION : 10,
+ // Initially, false, set to true once the page is fully loaded.
+
+ pageLoaded : false,
+
+ /**
+ * Invoked from onclick event handlers built into links and forms. Raises a \
dialog + * if the page is not yet fully loaded.
+ */
+ waitForPage : function(event)
+ {
+ if (Tapestry.pageLoaded) return;
+
+ // TODO: Figure out how to make this work in IE!
+
+ event.preventDefault();
+
+ var body = $$("BODY").first();
+
+ // The overlay is stretched to cover the full screen (including scrolling \
areas) + // and is used to fade out the background ... and prevent keypresses \
(its z-order helps there). +
+ var overlay = new Element("div", { 'class' : 't-dialog-overlay' });
+ overlay.setOpacity(0.0);
+
+ // This seems to leave a few pixels at the bottom uncovered; a problem for \
another day. +
+ overlay.style.height = body.getHeight() + "px";
+
+ body.insert({ top: overlay });
+
+ // Fade it in to 30% opacity
+
+ new Effect.Appear(overlay, {duration: 0.2, from: 0.0, to: 0.3});
+
+ var messageDiv = new Element("div", { 'class' : 't-page-loading-banner' \
}).update(Tapestry.Messages.pageIsLoading); + overlay.insert({ top: messageDiv \
}); +
+ var hideDialog = function()
+ {
+ new Effect.Fade(overlay, { duration: 0.2,
+ afterFinish: function()
+ {
+ overlay.remove();
+ } });
+ };
+
+ document.observe("dom:loaded", hideDialog);
+ },
+
+
// Adds a callback function that will be invoked when the DOM is loaded (which
// occurs *before* window.onload, which has to wait for images and such to load
// first. This simply observes the dom:loaded event on the document object \
(support for @@ -67,6 +117,10 @@
*/
onDomLoadedCallback : function()
{
+ // Turn off click & submit protection inside Tapestry.waitForPage().
+
+ Tapestry.pageLoaded = true;
+
Tapestry.ScriptManager.initialize();
$$(".t-invisible").each(function(element)
@@ -485,6 +539,12 @@
};
+Tapestry.Messages = {
+
+ pageIsLoading : "Please wait for the page to finish loading ..."
+
+};
+
Element.addMethods(
{
@@ -1190,7 +1250,6 @@
this.icon = $(id + ':icon');
this.translator = Prototype.K;
- // this.requiredCheck = Prototype.emptyFunction;
document.observe(Tapestry.FOCUS_CHANGE_EVENT, function(event)
{
@@ -1306,26 +1365,31 @@
Tapestry.ElementEffect = {
+ /** Fades in the element. */
show : function(element)
{
return new Effect.Appear(element);
},
+ /** The classic yellow background fade. */
highlight : function(element)
{
return new Effect.Highlight(element);
},
+ /** Scrolls the content down. */
slidedown : function (element)
{
return new Effect.SlideDown(element);
},
+ /** Slids the content back up (opposite of slidedown). */
slideup : function(element)
{
return new Effect.SlideUp(element);
},
+ /** Fades the content out (opposite of show). */
fade : function(element)
{
return new Effect.Fade(element);
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/SlowAjaxDemo.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/SlowAjaxDemo.tml?rev=748906&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/SlowAjaxDemo.tml (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/SlowAjaxDemo.tml Sat Feb 28 \
19:09:57 2009 @@ -0,0 +1,29 @@
+<t:border title="Slow Ajax Demo" \
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd" + \
xmlns:p="tapestry:parameter"> +
+
+ <t:zone t:id="zone">
+ <t:if test="zoneMessage">
+ <p id="zoneOutput">${zoneMessage}</p>
+ </t:if>
+ </t:zone>
+
+ <ul>
+ <li>
+ <t:pagelink page="slowajaxdemo">refresh</t:pagelink>
+ </li>
+ <li>
+ <t:actionlink t:id="link" zone="zone">action</t:actionlink>
+ </li>
+ <li>
+ <t:form zone="zone">
+ <t:linksubmit>link submit</t:linksubmit>
+ <input type="submit" value="Ordinary Submit"/>
+ </t:form>
+ </li>
+ </ul>
+
+
+ <script src="${slowScriptLink}"/>
+
+</t:border>
\ No newline at end of file
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java \
/org/apache/tapestry5/integration/IntegrationTests.java?rev=748906&r1=748905&r2=748906&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java \
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java \
Sat Feb 28 19:09:57 2009 @@ -2710,4 +2710,53 @@
waitForElementToAppear("content2");
assertText("content2", "Music Library");
}
+
+ /**
+ * TAP5-544
+ */
+ public void slow_ajax_load_warning()
+ {
+ start("Slow Ajax Demo");
+
+ // ActionLink
+
+ click("link=action");
+
+ waitForElementToAppear("slow");
+
+ click("link=action");
+
+ waitForElementToAppear("zoneOutput");
+
+ assertText("zoneOutput", "Updated via an ActionLink");
+
+ // LinkSubmit
+
+ clickAndWait("link=refresh");
+
+ click("link=link submit");
+
+ waitForElementToAppear("slow");
+
+ click("link=link submit");
+
+ waitForElementToAppear("zoneOutput");
+
+ assertText("zoneOutput", "Updated via form submission.");
+
+
+ // Normal submit
+
+ clickAndWait("link=refresh");
+
+ click(SUBMIT);
+
+ waitForElementToAppear("slow");
+
+ click(SUBMIT);
+
+ waitForElementToAppear("zoneOutput");
+
+ assertText("zoneOutput", "Updated via form submission.");
+ }
}
\ No newline at end of file
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java \
/org/apache/tapestry5/integration/app1/pages/Index.java?rev=748906&r1=748905&r2=748906&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java \
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java \
Sat Feb 28 19:09:57 2009 @@ -65,6 +65,8 @@
private static final List<Item> ITEMS = CollectionFactory.newList(
+ new Item("SlowAjaxDemo", "Slow Ajax Demo", "Handling of client-side Ajax \
before the page is fully loaded"), +
new Item("ProgressiveDemo", "ProgressiveDisplay Demo", "Progressive \
Enhancement via a component"),
new Item("ClientNumericValidationDemo", "Client-Side Numeric \
Validation",
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/SlowAjaxDemo.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java \
/org/apache/tapestry5/integration/app1/pages/SlowAjaxDemo.java?rev=748906&view=auto \
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/SlowAjaxDemo.java \
(added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/SlowAjaxDemo.java \
Sat Feb 28 19:09:57 2009 @@ -0,0 +1,69 @@
+// Copyright 2009 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry5.integration.app1.pages;
+
+import org.apache.tapestry5.ComponentResources;
+import org.apache.tapestry5.Link;
+import org.apache.tapestry5.annotations.InjectComponent;
+import org.apache.tapestry5.annotations.Property;
+import org.apache.tapestry5.corelib.components.Zone;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.apache.tapestry5.util.TextStreamResponse;
+
+public class SlowAjaxDemo
+{
+ @Property
+ private String zoneMessage;
+
+ @InjectComponent
+ private Zone zone;
+
+ @Inject
+ private ComponentResources resources;
+
+ Object onActionFromLink()
+ {
+ zoneMessage = "Updated via an ActionLink";
+
+ return zone.getBody();
+ }
+
+ Object onSuccessFromForm()
+ {
+ zoneMessage = "Updated via form submission.";
+
+ return zone.getBody();
+ }
+
+ public Link getSlowScriptLink()
+ {
+ return resources.createEventLink("slowScript");
+ }
+
+ Object onSlowScript()
+ {
+ try
+ {
+ Thread.sleep(2 * 1000);
+ }
+ catch (Exception ex)
+ {
+ }
+
+ return new TextStreamResponse("text/javascript",
+ "document.write(\"<p id='slow'>Slow script \
loaded.</p>\");"); +
+ }
+}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/DocumentLinkerImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java \
/org/apache/tapestry5/internal/services/DocumentLinkerImplTest.java?rev=748906&r1=748905&r2=748906&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/DocumentLinkerImplTest.java \
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/DocumentLinkerImplTest.java \
Sat Feb 28 19:09:57 2009 @@ -34,7 +34,7 @@
document.newRootElement("not-html").text("not an HTML document");
- DocumentLinkerImpl linker = new DocumentLinkerImpl(true, false, true, \
"1.2.3"); + DocumentLinkerImpl linker = new DocumentLinkerImpl(true, true, \
"1.2.3");
// Only checked if there's something to link.
@@ -60,7 +60,7 @@
document.newRootElement("not-html").text("not an HTML document");
- DocumentLinkerImpl linker = new DocumentLinkerImpl(true, false, true, \
"1.2.3"); + DocumentLinkerImpl linker = new DocumentLinkerImpl(true, true, \
"1.2.3");
// Only checked if there's something to link.
@@ -82,7 +82,7 @@
{
Document document = new Document();
- DocumentLinkerImpl linker = new DocumentLinkerImpl(true, false, true, \
"1.2.3"); + DocumentLinkerImpl linker = new DocumentLinkerImpl(true, true, \
"1.2.3");
linker.addScript("foo.js");
linker.addScript("doSomething();");
@@ -99,7 +99,7 @@
document.newRootElement("html").element("body").element("p").text("Ready to \
be updated with scripts.");
- DocumentLinkerImpl linker = new DocumentLinkerImpl(true, false, true, \
"1.2.3"); + DocumentLinkerImpl linker = new DocumentLinkerImpl(true, true, \
"1.2.3");
linker.addScriptLink("foo.js");
linker.addScriptLink("bar/baz.js");
@@ -120,7 +120,7 @@
document.newRootElement("html").element("body").element("p").text("Ready to \
be marked with generator meta.");
- DocumentLinkerImpl linker = new DocumentLinkerImpl(true, false, false, \
"1.2.3"); + DocumentLinkerImpl linker = new DocumentLinkerImpl(true, false, \
"1.2.3");
linker.updateDocument(document);
@@ -135,7 +135,7 @@
document.newRootElement("html");
- DocumentLinkerImpl linker = new DocumentLinkerImpl(true, true, true, \
"1.2.3"); + DocumentLinkerImpl linker = new DocumentLinkerImpl(true, true, \
"1.2.3");
linker.addStylesheetLink("style.css", "print");
linker.addScriptLink("foo.js");
@@ -148,32 +148,13 @@
}
@Test
- public void empty_document_with_scripts_at_bottom() throws Exception
- {
- Document document = new Document(new XMLMarkupModel());
-
- document.newRootElement("html");
-
- DocumentLinkerImpl linker = new DocumentLinkerImpl(true, false, true, \
"1.2.3");
-
- linker.addStylesheetLink("style.css", "print");
- linker.addScriptLink("foo.js");
- linker.addScriptLink("bar/baz.js");
- linker.addScript("pageInitialization();");
-
- linker.updateDocument(document);
-
- check(document, "empty_document_with_scripts_at_bottom.txt");
- }
-
- @Test
public void add_script_links_at_top() throws Exception
{
Document document = new Document(new XMLMarkupModel());
document.newRootElement("html").element("body").element("p").text("Ready to \
be updated with scripts at top.");
- DocumentLinkerImpl linker = new DocumentLinkerImpl(true, true, true, \
"1.2.3"); + DocumentLinkerImpl linker = new DocumentLinkerImpl(true, true, \
"1.2.3");
linker.addScriptLink("foo.js");
linker.addScriptLink("bar/baz.js");
@@ -191,7 +172,7 @@
document.newRootElement("html").element("body").element("p").text("Ready to \
be updated with styles.");
- DocumentLinkerImpl linker = new DocumentLinkerImpl(true, false, true, \
"1.2.3"); + DocumentLinkerImpl linker = new DocumentLinkerImpl(true, true, \
"1.2.3");
linker.addStylesheetLink("foo.css", null);
linker.addStylesheetLink("bar/baz.css", "print");
@@ -208,7 +189,7 @@
document.newRootElement("html").element("body").element("p").text("Ready to \
be updated with styles.");
- DocumentLinkerImpl linker = new DocumentLinkerImpl(true, false, true, \
"1.2.3"); + DocumentLinkerImpl linker = new DocumentLinkerImpl(true, true, \
"1.2.3");
linker.addStylesheetLink("foo.css", null);
linker.addStylesheetLink("bar/baz.css", "print");
@@ -229,7 +210,7 @@
document.newRootElement("html").element("head").comment("existing \
head").getParent()
.element("body").text("body content");
- DocumentLinkerImpl linker = new DocumentLinkerImpl(true, false, true, \
"1.2.3"); + DocumentLinkerImpl linker = new DocumentLinkerImpl(true, true, \
"1.2.3");
linker.addStylesheetLink("foo.css", null);
@@ -245,7 +226,7 @@
document.newRootElement("html").element("body").element("p").text("Ready to \
be updated with scripts.");
- DocumentLinkerImpl linker = new DocumentLinkerImpl(true, false, true, \
"1.2.3"); + DocumentLinkerImpl linker = new DocumentLinkerImpl(true, true, \
"1.2.3");
for (int i = 0; i < 3; i++)
{
@@ -266,7 +247,7 @@
document.newRootElement("html").element("body").element("p").text("Ready to \
be updated with scripts.");
- DocumentLinkerImpl linker = new DocumentLinkerImpl(true, false, true, \
"1.2.3"); + DocumentLinkerImpl linker = new DocumentLinkerImpl(true, true, \
"1.2.3");
linker.addScript("doSomething();");
linker.addScript("doSomethingElse();");
@@ -283,7 +264,7 @@
document.newRootElement("html").element("body").element("p").text("Ready to \
be updated with scripts.");
- DocumentLinkerImpl linker = new DocumentLinkerImpl(false, false, true, \
"1.2.3"); + DocumentLinkerImpl linker = new DocumentLinkerImpl(false, true, \
"1.2.3");
linker.addScriptLink("foo.js");
@@ -302,7 +283,7 @@
document.newRootElement("html").element("notbody").element("p").text("Ready \
to be updated with scripts.");
- DocumentLinkerImpl linker = new DocumentLinkerImpl(true, false, true, \
"1.2.3"); + DocumentLinkerImpl linker = new DocumentLinkerImpl(true, true, \
"1.2.3");
linker.addScriptLink("foo.js");
@@ -319,7 +300,7 @@
document.newRootElement("html").element("body").element("p").text("Ready to \
be updated with scripts.");
- DocumentLinkerImpl linker = new DocumentLinkerImpl(true, false, true, \
"1.2.3"); + DocumentLinkerImpl linker = new DocumentLinkerImpl(true, true, \
"1.2.3");
linker.addScript("for (var i = 0; i < 5; i++) { doIt(i); }");
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/internal/services/add_script.txt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/reso \
urces/org/apache/tapestry5/internal/services/add_script.txt?rev=748906&r1=748905&r2=748906&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/internal/services/add_script.txt \
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/internal/services/add_script.txt \
Sat Feb 28 19:09:57 2009 @@ -1,4 +1,4 @@
-<html><body><p>Ready to be updated with \
scripts.</p><script>Tapestry.onDOMLoaded(function() { \
+<html><head></head><body><p>Ready to be updated with \
scripts.</p><script>Tapestry.onDOMLoaded(function() { doSomething();
doSomethingElse();
});
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/internal/services/add_script_in_development_mode.txt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/reso \
urces/org/apache/tapestry5/internal/services/add_script_in_development_mode.txt?rev=748906&r1=748905&r2=748906&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/internal/services/add_script_in_development_mode.txt \
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/internal/services/add_script_in_development_mode.txt \
Sat Feb 28 19:09:57 2009 @@ -1,4 +1,4 @@
-<html><body><p>Ready to be updated with scripts.</p><script \
src="foo.js"></script><script>Tapestry.DEBUG_ENABLED = true; +<html><head><script \
src="foo.js"></script></head><body><p>Ready to be updated with \
scripts.</p><script>Tapestry.DEBUG_ENABLED = true; Tapestry.onDOMLoaded(function() {
});
</script></body></html>
\ No newline at end of file
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/internal/services/add_script_links.txt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/reso \
urces/org/apache/tapestry5/internal/services/add_script_links.txt?rev=748906&r1=748905&r2=748906&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/internal/services/add_script_links.txt \
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/internal/services/add_script_links.txt \
Sat Feb 28 19:09:57 2009 @@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<html><body><p>Ready to be updated with scripts.</p><script src="foo.js"/><script \
src="bar/baz.js"/><script>Tapestry.onDOMLoaded(function() { +<html><head><script \
src="foo.js"/><script src="bar/baz.js"/></head><body><p>Ready to be updated with \
scripts.</p><script>Tapestry.onDOMLoaded(function() { pageInitialization();
});
</script></body></html>
\ No newline at end of file
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/internal/services/duplicate_script_links_ignored.txt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/reso \
urces/org/apache/tapestry5/internal/services/duplicate_script_links_ignored.txt?rev=748906&r1=748905&r2=748906&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/internal/services/duplicate_script_links_ignored.txt \
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/internal/services/duplicate_script_links_ignored.txt \
Sat Feb 28 19:09:57 2009 @@ -1 +1 @@
-<html><body><p>Ready to be updated with scripts.</p><script \
src="foo.js"></script><script src="bar/baz.js"></script><script \
src="biff.js"></script></body></html> \ No newline at end of file
+<html><head><script src="foo.js"></script><script src="bar/baz.js"></script><script \
src="biff.js"></script></head><body><p>Ready to be updated with \
scripts.</p></body></html> \ No newline at end of file
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/internal/services/no_body_element.txt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/reso \
urces/org/apache/tapestry5/internal/services/no_body_element.txt?rev=748906&r1=748905&r2=748906&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/internal/services/no_body_element.txt \
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/internal/services/no_body_element.txt \
Sat Feb 28 19:09:57 2009 @@ -1,2 +1,2 @@
<?xml version="1.0"?>
-<html><notbody><p>Ready to be updated with scripts.</p></notbody><body><script \
src="foo.js"/></body></html> \ No newline at end of file
+<html><head><script src="foo.js"/></head><notbody><p>Ready to be updated with \
scripts.</p></notbody><body/></html> \ No newline at end of file
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/internal/services/script_written_raw.txt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/reso \
urces/org/apache/tapestry5/internal/services/script_written_raw.txt?rev=748906&r1=748905&r2=748906&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/internal/services/script_written_raw.txt \
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/internal/services/script_written_raw.txt \
Sat Feb 28 19:09:57 2009 @@ -1,4 +1,4 @@
-<html><body><p>Ready to be updated with \
scripts.</p><script>Tapestry.onDOMLoaded(function() { \
+<html><head></head><body><p>Ready to be updated with \
scripts.</p><script>Tapestry.onDOMLoaded(function() { for (var i = 0; i < 5; i++) { \
doIt(i); } });
</script></body></html>
\ No newline at end of file
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic