Convert Tapestry.waitForPage() into a no-op, and change existing components to not make use of it
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/6792fcf9 Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/6792fcf9 Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/6792fcf9 Branch: refs/heads/5.4-js-rewrite Commit: 6792fcf9b4cf7babb75e1532410e243aaa4b16ec Parents: 2ae9d0a Author: Howard M. Lewis Ship <[email protected]> Authored: Tue Aug 14 18:24:25 2012 -0700 Committer: Howard M. Lewis Ship <[email protected]> Committed: Tue Aug 14 18:24:25 2012 -0700 ---------------------------------------------------------------------- 54_RELEASE_NOTES.txt | 7 ++- .../java/org/apache/tapestry5/MarkupConstants.java | 5 +- .../corelib/base/AbstractComponentEventLink.java | 6 +- .../apache/tapestry5/corelib/components/Form.java | 5 - .../corelib/components/ProgressiveDisplay.tml | 3 +- .../resources/org/apache/tapestry5/default.css | 24 ----- .../org/apache/tapestry5/dialog-background.gif | Bin 1526 -> 0 bytes .../resources/org/apache/tapestry5/tapestry.js | 59 +------------ tapestry-core/src/test/app1/SlowAjaxDemo.tml | 29 ------ .../tapestry5/integration/app1/AjaxTests.java | 33 ------- .../tapestry5/integration/app1/ZoneTests.java | 22 ----- .../tapestry5/integration/app1/pages/Index.java | 5 +- .../integration/app1/pages/SlowAjaxDemo.java | 69 --------------- 13 files changed, 16 insertions(+), 251 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6792fcf9/54_RELEASE_NOTES.txt ---------------------------------------------------------------------- diff --git a/54_RELEASE_NOTES.txt b/54_RELEASE_NOTES.txt index 2b648dd..bbd7ab5 100644 --- a/54_RELEASE_NOTES.txt +++ b/54_RELEASE_NOTES.txt @@ -73,4 +73,9 @@ was introduced in Tapestry 5.2, and has now been removed. Tapestry.FormEventManager has been entirely removed, along with supporting function Element.getFormEventManager(). -Tapestry.FieldEventManager.getIcon() now always returns null. \ No newline at end of file +Tapestry.FieldEventManager.getIcon() now always returns null. + +Tapestry 5.3 contained code that attempted to prevent Ajax requests until after the page had loaded; this was based +on the function Tapestry.waitForPage(). Server components no longer make use of this function, and the function +itself now does nothing. A replacement approach to preventing the user from interacting with links and forms before +the page initialization has completed may be implemented in the future. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6792fcf9/tapestry-core/src/main/java/org/apache/tapestry5/MarkupConstants.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/MarkupConstants.java b/tapestry-core/src/main/java/org/apache/tapestry5/MarkupConstants.java index b4f3a0b..b011783 100644 --- a/tapestry-core/src/main/java/org/apache/tapestry5/MarkupConstants.java +++ b/tapestry-core/src/main/java/org/apache/tapestry5/MarkupConstants.java @@ -1,4 +1,4 @@ -// Copyright 2011 The Apache Software Foundation +// Copyright 2009, 2011, 2012 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. @@ -26,6 +26,8 @@ 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. References a client-side JavaScript function that displays a standard "wait for * page to load" modal dialog. + * + * @deprecated Deprecated in Tapestry 5.4 with no replacement. Do not use. */ public static final String WAIT_FOR_PAGE = "javascript:return Tapestry.waitForPage(event);"; @@ -33,6 +35,7 @@ public class MarkupConstants * Name of attribute for intercepting the user clicking a link. * * @see #WAIT_FOR_PAGE + * @deprecated Deprecated in Tapestry 5.4 with no replacement. Do not use. */ public static final String ONCLICK = "onclick"; } http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6792fcf9/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractComponentEventLink.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractComponentEventLink.java b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractComponentEventLink.java index 1752cc5..97fcd34 100644 --- a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractComponentEventLink.java +++ b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractComponentEventLink.java @@ -1,4 +1,4 @@ -// Copyright 2008, 2009 The Apache Software Foundation +// Copyright 2008, 2009, 2011 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. @@ -16,7 +16,6 @@ package org.apache.tapestry5.corelib.base; 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; @@ -60,9 +59,6 @@ public abstract class AbstractComponentEventLink extends AbstractLink if (zone != null) { - if (!request.isXHR()) - writer.getElement().forceAttributes(MarkupConstants.ONCLICK, MarkupConstants.WAIT_FOR_PAGE); - clientBehaviorSupport.linkZone(getClientId(), zone, link); } } http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6792fcf9/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java index d8e0f4d..9ea3b63 100644 --- a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java +++ b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java @@ -355,11 +355,6 @@ public class Form implements ClientElement, FormValidationControl form = writer.element("form", "id", clientId, "method", "post", "action", actionURL); - if ((zone != null || clientValidation != ClientValidation.NONE) && !request.isXHR()) - { - writer.attributes("onsubmit", MarkupConstants.WAIT_FOR_PAGE); - } - if (clientValidation != ClientValidation.NONE) { writer.attributes("data-t5-validate", "submit"); http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6792fcf9/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/ProgressiveDisplay.tml ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/ProgressiveDisplay.tml b/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/ProgressiveDisplay.tml index 720290b..8a9ac91 100644 --- a/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/ProgressiveDisplay.tml +++ b/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/ProgressiveDisplay.tml @@ -1,5 +1,4 @@ -<t:container xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd" - > +<t:container xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd"> <t:block id="defaultInitial"> <div class="t-loading">${message:core-progressive-display-loading}</div> </t:block> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6792fcf9/tapestry-core/src/main/resources/org/apache/tapestry5/default.css ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/resources/org/apache/tapestry5/default.css b/tapestry-core/src/main/resources/org/apache/tapestry5/default.css index cbc4c76..92a3e37 100644 --- a/tapestry-core/src/main/resources/org/apache/tapestry5/default.css +++ b/tapestry-core/src/main/resources/org/apache/tapestry5/default.css @@ -453,30 +453,6 @@ DIV.t-loading { background: transparent url(ajax-loader.gif) no-repeat right top; } -DIV.t-dialog-overlay { - position: fixed; - margin: auto; - top: 0px; - left: 0px; - z-index: 9990; - width: 100%; - height: 100%; - background: transparent url("dialog-background.gif"); -} - -DIV.t-page-loading-banner { - position: absolute; - top: 5px; - left: 5px; - width: auto; - font-weight: bold; - padding: 2px 4px 2px 24px; - color: black; - background: white url(ajax-loader.gif) no-repeat 4px center; - border-right: 2px solid black; - border-bottom: 2px solid black; -} - SPAN.t-render-object-error { font-weight: bold; font: italic; http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6792fcf9/tapestry-core/src/main/resources/org/apache/tapestry5/dialog-background.gif ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/resources/org/apache/tapestry5/dialog-background.gif b/tapestry-core/src/main/resources/org/apache/tapestry5/dialog-background.gif deleted file mode 100644 index ef98d9d..0000000 Binary files a/tapestry-core/src/main/resources/org/apache/tapestry5/dialog-background.gif and /dev/null differ http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6792fcf9/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js b/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js index 92ee51c..743da36 100644 --- a/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js +++ b/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js @@ -117,63 +117,10 @@ define("core/compat/tapestry", [ /** * Invoked from onclick event handlers built into links and forms. Raises a - * dialog if the page is not yet fully loaded. + * dialog if the page is not yet fully loaded. Gutted in 5.4, does nothing ... + * the page loads fast enough :-). */ - waitForPage: function (event) { - if (Tapestry.pageLoaded) - return true; - - Event.extend(event || window.event).stop(); - - var body = $(document.body); - - /* - * 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); - - body.insert({ - top: overlay - }); - - new Effect.Appear(overlay, { - duration: 0.2, - from: 0.0 - }); - - 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 () { - Tapestry.remove(overlay); - } - }); - }; - - document.observe("dom:loaded", hideDialog); - - /* A rare race condition. */ - - if (Tapestry.pageLoaded) { - hideDialog.call(null); - - return true; - } else { - return false; - } - + waitForPage: function () { }, /** http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6792fcf9/tapestry-core/src/test/app1/SlowAjaxDemo.tml ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/app1/SlowAjaxDemo.tml b/tapestry-core/src/test/app1/SlowAjaxDemo.tml deleted file mode 100644 index 1950eaf..0000000 --- a/tapestry-core/src/test/app1/SlowAjaxDemo.tml +++ /dev/null @@ -1,29 +0,0 @@ -<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 http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6792fcf9/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/AjaxTests.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/AjaxTests.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/AjaxTests.java index 748e586..b871a90 100644 --- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/AjaxTests.java +++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/AjaxTests.java @@ -226,39 +226,6 @@ public class AjaxTests extends TapestryCoreTestCase } /** - * TAP5-544 - */ - @Test - public void slow_ajax_load_warning() - { - openLinks("Slow Ajax Demo"); - - // ActionLink - - click("//a[@id='link']"); - - waitForElementToAppear("slow"); - - click("//a[@id='link']"); - - waitForElementToAppear("zoneOutput"); - - assertText("zoneOutput", "Updated via an ActionLink"); - - clickAndWait("link=refresh"); - - click(SUBMIT); - - waitForElementToAppear("slow"); - - click(SUBMIT); - - waitForElementToAppear("zoneOutput"); - - assertText("zoneOutput", "Updated via form submission."); - } - - /** * TAP5-236 */ @Test http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6792fcf9/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/ZoneTests.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/ZoneTests.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/ZoneTests.java index 5fc545c..c4b490e 100644 --- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/ZoneTests.java +++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/ZoneTests.java @@ -212,28 +212,6 @@ public class ZoneTests extends TapestryCoreTestCase assertTextPresent(Form.class.getName() + "[form--form]"); } - /** - * TAP5-707 - */ - @Test - public void zone_fade_back_backgroundcolor() - { - openLinks("Form Zone Demo"); - - type("longValue", "12"); - - click(SUBMIT); - - click(SUBMIT); - - // wait some time to let the fade go away - sleep(4050); - - // will only work in firefox. - String color = getEval("selenium.browserbot.getCurrentWindow().getComputedStyle(this.page().findElement(\"xpath=//div[@id='valueZone']\"),'').getPropertyValue('background-color').toLowerCase()"); - - assertEquals(color, "rgb(255, 255, 255)"); - } /** * TAP5-1084 http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6792fcf9/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java index 7de773f..3d37f8e 100644 --- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java +++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java @@ -156,9 +156,6 @@ public class Index new Item("LinkSubmitInZoneDemo", "LinkSubmit inside Zone", "Ensure that a LinkSubmit works correctly when its containing Form updates a Zone"), - 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", @@ -368,7 +365,7 @@ public class Index "Demo the autocomplete mixin for text fields"), new Item("componentparameter", "ComponentParameter Demo", - " Demo using a component type as a parameter type and succesfuly passing a component"), + " Demo using a component type as a parameter type and succesfully passing a component"), new Item("inheritinformalsdemo", "Inherit Informal Parameters Demo", "Demo a component which inherits informal parameters from its container"), http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6792fcf9/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/SlowAjaxDemo.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/SlowAjaxDemo.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/SlowAjaxDemo.java deleted file mode 100644 index 1d55cf7..0000000 --- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/SlowAjaxDemo.java +++ /dev/null @@ -1,69 +0,0 @@ -// 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>\");"); - - } -}
