Tapestry 5
  1. Tapestry 5
  2. TAP5-1539

Optimize document scans used by Tapestry.FieldEventManager to not locate the label or icon until actually needed

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 5.3, 5.2.4
    • Fix Version/s: 5.3, 5.2.6
    • Component/s: tapestry-core
    • Labels:

      Description

      While creating the Field Event Manager we are initializing not only the basic features but also extra information for being use later, like label and icon.

      For getting the icon we need to search for the element in the DOM (using a $) and for the label it is searching the DOM for a specific label, which is a very expensive operation in ie7.

      If we move the initialization of these elements until they are really needed, we are saving some client side timing.

          1. Eclipse Workspace Patch 1.0
            #P tapestry-core
            Index: src/main/resources/org/apache/tapestry5/tapestry.js
            ===================================================================
          • src/main/resources/org/apache/tapestry5/tapestry.js (revision 1131061)
            +++ src/main/resources/org/apache/tapestry5/tapestry.js (working copy)
            @@ -1667,13 +1667,6 @@
            initialize : function(field) { this.field = $(field); - var id = this.field.id; - - var selector = "label[for='" + id + "']"; - - this.label = this.field.up("form").down(selector); - this.icon = $(id + '_icon'); - this.translator = Prototype.K; var fem = $(this.field.form).getFormEventManager(); @@ -1698,7 +1691,24 @@ this.validateInput.bindAsEventListener(this)); }

            },
            +
            + getLabel : function()

            Unknown macro: {+ if (!this.label) { + var id = this.field.id; + var selector = "label[for='" + id + "']"; + this.label = this.field.form.down(selector); + }+ return this.label;+ }

            ,

      + getIcon : function() {
      + if (!this.icon)

      { + var id = this.field.id; + this.icon = $(id + '_icon'); + }

      + return this.icon;
      + },
      +
      /**

      • Removes validation decorations if present. Hides the ErrorPopup, if it
      • exists.
        @@ -1706,11 +1716,11 @@
        removeDecorations : function() {
        this.field.removeClassName("t-error");
      • if (this.label)
      • this.label.removeClassName("t-error");
        + if (this.getLabel())
        + this.getLabel().removeClassName("t-error");
      • if (this.icon)
      • this.icon.hide();
        + if (this.getIcon())
        + this.getIcon().hide();

      if (this.errorPopup)
      this.errorPopup.hide();
      @@ -1730,12 +1740,12 @@

      this.field.addClassName("t-error");

      • if (this.label)
      • this.label.addClassName("t-error");
        + if (this.getLabel())
        + this.getLabel().addClassName("t-error");
      • if (this.icon) {
      • if (!this.icon.visible())
      • new Effect.Appear(this.icon);
        + if (this.getIcon()) { + if (!this.getIcon().visible()) + new Effect.Appear(this.getIcon()); }

      if (this.errorPopup == undefined)

        Activity

        Hide
        Howard M. Lewis Ship added a comment -

        I appreciate the patch, but it's only useful as an attachment, not inline. It gets too corrupted by being translated to HTML by Jira.

        Show
        Howard M. Lewis Ship added a comment - I appreciate the patch, but it's only useful as an attachment, not inline. It gets too corrupted by being translated to HTML by Jira.
        Hide
        Howard M. Lewis Ship added a comment -

        This would be another issue that would be backported to 5.2.6, if such as release is ever created.

        Show
        Howard M. Lewis Ship added a comment - This would be another issue that would be backported to 5.2.6, if such as release is ever created.
        Hide
        Hudson added a comment -

        Integrated in tapestry-trunk-freestyle #359 (See https://builds.apache.org/hudson/job/tapestry-trunk-freestyle/359/)
        TAP5-1539: Optimize document scans used by Tapestry.FieldEventManager to not locate the label or icon until actually needed

        hlship : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1131297
        Files :

        • /tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
        Show
        Hudson added a comment - Integrated in tapestry-trunk-freestyle #359 (See https://builds.apache.org/hudson/job/tapestry-trunk-freestyle/359/ ) TAP5-1539 : Optimize document scans used by Tapestry.FieldEventManager to not locate the label or icon until actually needed hlship : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1131297 Files : /tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
        Hide
        Howard M. Lewis Ship added a comment -

        For backport

        Show
        Howard M. Lewis Ship added a comment - For backport
        Hide
        Hudson added a comment -

        Integrated in tapestry-trunk-freestyle #577 (See https://builds.apache.org/job/tapestry-trunk-freestyle/577/)
        TAP5-1539: Update a few places to use Runnable not (deprecated) RegistryShutdownListener
        TAP5-1539: Add registry will shutdown notifications

        Deprecated RegistyDidShutdownListener ... a Runnable will due as well
        Added methods to registry Runnables as "did" and "will" shutdown listeners

        hlship : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1183527
        Files :

        • /tapestry/tapestry5/trunk/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/hibernate/HibernateCoreModule.java
        • /tapestry/tapestry5/trunk/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/internal/hibernate/HibernateSessionSourceImpl.java
        • /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/RegistryImpl.java
        • /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/JustInTimeObjectCreator.java
        • /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/cron/PeriodicExecutorImpl.java
        • /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/TapestryIOCModule.java
        • /tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/JustInTimeObjectCreatorTest.java
        • /tapestry/tapestry5/trunk/tapestry-jmx/src/main/java/org/apache/tapestry5/internal/jmx/MBeanSupportImpl.java
        • /tapestry/tapestry5/trunk/tapestry-jpa/src/main/java/org/apache/tapestry5/internal/jpa/EntityManagerSourceImpl.java
        • /tapestry/tapestry5/trunk/tapestry-jpa/src/main/java/org/apache/tapestry5/jpa/JpaModule.java
        • /tapestry/tapestry5/trunk/tapestry-spring/src/main/java/org/apache/tapestry5/internal/spring/SpringModuleDef.java
        • /tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/services/UploadModule.java

        hlship : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1183526
        Files :

        • /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/RegistryImpl.java
        • /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/RegistryShutdownHubImpl.java
        • /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/cron/PeriodicExecutorImpl.java
        • /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/RegistryShutdownHub.java
        • /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/RegistryShutdownListener.java
        • /tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/RegistryShutdownHubImplTest.java
        Show
        Hudson added a comment - Integrated in tapestry-trunk-freestyle #577 (See https://builds.apache.org/job/tapestry-trunk-freestyle/577/ ) TAP5-1539 : Update a few places to use Runnable not (deprecated) RegistryShutdownListener TAP5-1539 : Add registry will shutdown notifications Deprecated RegistyDidShutdownListener ... a Runnable will due as well Added methods to registry Runnables as "did" and "will" shutdown listeners hlship : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1183527 Files : /tapestry/tapestry5/trunk/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/hibernate/HibernateCoreModule.java /tapestry/tapestry5/trunk/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/internal/hibernate/HibernateSessionSourceImpl.java /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/RegistryImpl.java /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/JustInTimeObjectCreator.java /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/cron/PeriodicExecutorImpl.java /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/TapestryIOCModule.java /tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/JustInTimeObjectCreatorTest.java /tapestry/tapestry5/trunk/tapestry-jmx/src/main/java/org/apache/tapestry5/internal/jmx/MBeanSupportImpl.java /tapestry/tapestry5/trunk/tapestry-jpa/src/main/java/org/apache/tapestry5/internal/jpa/EntityManagerSourceImpl.java /tapestry/tapestry5/trunk/tapestry-jpa/src/main/java/org/apache/tapestry5/jpa/JpaModule.java /tapestry/tapestry5/trunk/tapestry-spring/src/main/java/org/apache/tapestry5/internal/spring/SpringModuleDef.java /tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/services/UploadModule.java hlship : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1183526 Files : /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/RegistryImpl.java /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/RegistryShutdownHubImpl.java /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/cron/PeriodicExecutorImpl.java /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/RegistryShutdownHub.java /tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/RegistryShutdownListener.java /tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/RegistryShutdownHubImplTest.java

          People

          • Assignee:
            Howard M. Lewis Ship
            Reporter:
            Pedro Ayala
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development