Tapestry
  1. Tapestry
  2. TAPESTRY-1259

EventListener generates duplicate javascript with page caching on

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Duplicate
    • Affects Version/s: 4.1.2
    • Fix Version/s: 4.1.2
    • Component/s: XHR/dhtml/Ajax
    • Labels:
      None
    • Environment:
      Tapestry 4.1.2-20070121 snapshot, Win XP, Firefox 2

      Description

      This may be related to TAPESTRY-1241 and/or TAPESTRY-1100. I have an EventListener for an onclick event that is supposed to update a string on the page when a link is clicked. When page caching is turned off, this works fine. When page pooling is turned on, duplicate chunks of javascript get output into the HTML depending on how deeply nested the component is. I have seen the exact same javascript output 2 or 3 times depending on where I put the link that is supposed to trigger the EventListener.

      Here is my link and string to get updated:
      <sessionData jwcid="@If" condition="prop:collectiveVisit.user.widenDev">
      <a jwcid="sessionData@Any" href="javascript:void(0);">View Hibernate Session Entities</a>
      <div id="theSessionData"><text jwcid="theSessionData@Insert" value="prop:theSessionData" mode="ognl:@org.apache.tapestry.components.InsertMode@BREAK" /></div>
      </sessionData>

      Here is the backing java code:
      public abstract boolean isShowSessionData();
      public abstract void setShowSessionData(boolean val);
      @EventListener(targets="sessionData", events="onclick")
      public void sessionDataClicked(IRequestCycle cycle)
      {
      setShowSessionData(true);
      cycle.getResponseBuilder().updateComponent("theSessionData");
      }
      public String getTheSessionData()
      {
      if (isShowSessionData())

      { return getSessionUtil().getSessionEntities(); }

      return "";
      }

      Here is an example of the duplicate javascript from the rendered HTML output:

      tapestry.cleanConnect(dojo.byId("sessionData"), "onclick", "event709189172");
      tapestry.event709189172=function(e){
      var content=

      {beventname:"onclick"}

      ;
      tapestry.event.buildEventProperties(e, content);
      if (!content["beventtarget.id"])

      { content["beventtarget.id"]="sessionData"; }
      tapestry.bind("/directevent.svc?component=border.sessionData&page=DirectorAccount&session=T", content);
      };
      dojo.event.connect(dojo.byId("sessionData"), "onclick", tapestry, "event709189172");
      tapestry.cleanConnect(dojo.byId("sessionData"), "onclick", "event709189172");
      tapestry.event709189172=function(e){
      var content={beventname:"onclick"};
      tapestry.event.buildEventProperties(e, content);
      if (!content["beventtarget.id"]) { content["beventtarget.id"]="sessionData"; }

      tapestry.bind("/directevent.svc?component=border.sessionData&page=DirectorAccount&session=T", content);
      };
      dojo.event.connect(dojo.byId("sessionData"), "onclick", tapestry, "event709189172");});

      As a result, when page caching is turned on (-Dorg.apache.tapestry.disable-caching=false), the string on the page never gets updated and I get a NullPointerException in the console:

      java.lang.NullPointerException
      at org.apache.tapestry.internal.event.impl.ComponentEventInvoker.invokeComponentListeners(ComponentEventInvoker.java:148)
      at org.apache.tapestry.internal.event.impl.ComponentEventInvoker.invokeListeners(ComponentEventInvoker.java:60)
      at $IComponentEventInvoker_110a2303c0a.invokeListeners($IComponentEventInvoker_110a2303c0a.java)
      at org.apache.tapestry.AbstractComponent.triggerEvent(AbstractComponent.java:879)
      at org.apache.tapestry.engine.DirectEventService.triggerComponent(DirectEventService.java:160)
      at org.apache.tapestry.engine.DirectEventService.service(DirectEventService.java:137)
      at $IEngineService_110a2303b97.service($IEngineService_110a2303b97.java)
      at org.apache.tapestry.services.impl.EngineServiceInnerProxy.service(EngineServiceInnerProxy.java:77)
      at org.apache.tapestry.services.impl.EngineServiceOuterProxy.service(EngineServiceOuterProxy.java:72)
      at org.apache.tapestry.engine.AbstractEngine.service(AbstractEngine.java:246)
      at org.apache.tapestry.services.impl.InvokeEngineTerminator.service(InvokeEngineTerminator.java:54)
      at $WebRequestServicer_110a2303b64.service($WebRequestServicer_110a2303b64.java)
      at $WebRequestServicer_110a2303b60.service($WebRequestServicer_110a2303b60.java)
      at org.apache.tapestry.services.impl.WebRequestServicerPipelineBridge.service(WebRequestServicerPipelineBridge.java:61)
      at $ServletRequestServicer_110a2303b42.service($ServletRequestServicer_110a2303b42.java)
      at org.apache.tapestry.request.DecodedRequestInjector.service(DecodedRequestInjector.java:55)
      at $ServletRequestServicerFilter_110a2303b3e.service($ServletRequestServicerFilter_110a2303b3e.java)
      at $ServletRequestServicer_110a2303b44.service($ServletRequestServicer_110a2303b44.java)
      at collective.ui.custom.HibernateFilter.service(HibernateFilter.java:37)
      at $ServletRequestServicerFilter_110a2303b3c.service($ServletRequestServicerFilter_110a2303b3c.java)
      at $ServletRequestServicer_110a2303b44.service($ServletRequestServicer_110a2303b44.java)
      at collective.ui.custom.LuceneIndexFilter.service(LuceneIndexFilter.java:24)
      at $ServletRequestServicerFilter_110a2303b3a.service($ServletRequestServicerFilter_110a2303b3a.java)
      at $ServletRequestServicer_110a2303b44.service($ServletRequestServicer_110a2303b44.java)
      at org.apache.tapestry.multipart.MultipartDecoderFilter.service(MultipartDecoderFilter.java:52)
      at $ServletRequestServicerFilter_110a2303b38.service($ServletRequestServicerFilter_110a2303b38.java)
      at $ServletRequestServicer_110a2303b44.service($ServletRequestServicer_110a2303b44.java)
      at org.apache.tapestry.services.impl.SetupRequestEncoding.service(SetupRequestEncoding.java:53)
      at $ServletRequestServicerFilter_110a2303b40.service($ServletRequestServicerFilter_110a2303b40.java)
      at $ServletRequestServicer_110a2303b44.service($ServletRequestServicer_110a2303b44.java)
      at $ServletRequestServicer_110a2303b31.service($ServletRequestServicer_110a2303b31.java)
      at org.apache.tapestry.ApplicationServlet.doService(ApplicationServlet.java:123)
      at collective.ui.CollectiveApplicationServlet.doService(CollectiveApplicationServlet.java:71)
      at org.apache.tapestry.ApplicationServlet.doGet(ApplicationServlet.java:104)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
      at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:427)
      at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:832)
      at collective.servlet.ResponseHeaderFilter.doFilter(ResponseHeaderFilter.java:32)
      at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:823)
      at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:473)
      at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:556)
      at org.mortbay.http.HttpContext.handle(HttpContext.java:1563)
      at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:623)
      at org.mortbay.http.HttpContext.handle(HttpContext.java:1515)
      at org.mortbay.http.HttpServer.service(HttpServer.java:956)
      at org.mortbay.http.HttpConnection.service(HttpConnection.java:814)
      at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:981)
      at org.mortbay.http.HttpConnection.handle(HttpConnection.java:831)
      at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:244)
      at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357)
      at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534)

        Activity

        Hide
        Ben Dotte added a comment -

        I think this is a duplicate of TAPESTRY-1241 based on the latest comments. Since that case has (or will be) fixed, I am marking this issue as resolved.

        Show
        Ben Dotte added a comment - I think this is a duplicate of TAPESTRY-1241 based on the latest comments. Since that case has (or will be) fixed, I am marking this issue as resolved.

          People

          • Assignee:
            Unassigned
            Reporter:
            Ben Dotte
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development