Tapestry
  1. Tapestry
  2. TAPESTRY-1241

@EventListener produces multiple events

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 4.1.1
    • Fix Version/s: 4.1.2
    • Component/s: XHR/dhtml/Ajax
    • Labels:
      None
    • Environment:
      Tapestry 4.1.1 and 4.1.2-20070121

      Description

      Adding an EventListener to the parent HTML element seems to add additional
      @EventListener to the Tapestry components on every Javascript event. This results
      in the generation of multiple "tapestry.event(hash)=function..." statements although
      only one is correct. This gets apparent when the page is submitted and re-rendered
      again.

      i added a maven2 example project to reproduce the bug.
      please follow these steps:
      1) click on "submit"
      2) click on the second and forth list element and watch the console (should print list-0 and list-2... the target component of the javascript event)
      3) click again on "submit" (you might change the value if you want)
      4) click again on the second list element and watch the console -> list-0 will appear twice
      5) take a look at the generated page to see the multiple tapestry.event statements

      1. EventListener.zip
        6 kB
        Kristian Marinkovic

        Activity

        Hide
        Jesse Kuhnert added a comment -

        Finally found it.

        Show
        Jesse Kuhnert added a comment - Finally found it.
        Hide
        Jesse Kuhnert added a comment -

        setting caching on did the trick, thanks. Should be fixed tomorrow.

        Show
        Jesse Kuhnert added a comment - setting caching on did the trick, thanks. Should be fixed tomorrow.
        Hide
        Kristian Marinkovic added a comment -

        hi jesse,

        i think i know why you can't reproduce the bug.
        Iis it possible you have org.apache.tapestry.disable-caching=true
        set? Caching must be enabled to reproduce this bug

        greetings,
        kris

        Show
        Kristian Marinkovic added a comment - hi jesse, i think i know why you can't reproduce the bug. Iis it possible you have org.apache.tapestry.disable-caching=true set? Caching must be enabled to reproduce this bug greetings, kris
        Hide
        Kristian Marinkovic added a comment -

        hi jesse,

        i just did a clean checkout and built tapestry 4.1.2-SNAPSHOT on my local machine.
        After starting up tomcat i could reproduce the bug (btw. some test fail ).

        The javascript code of the page looks like this when first started:

        dojo.addOnLoad(function(e) {
        dojo.require("tapestry.form");tapestry.form.registerForm("Form");
        tapestry.form.focusField('iteration');
        tapestry.cleanConnect(dojo.byId("ul"), "onclick", "event1675372791");
        tapestry.event1675372791=function(e){
        var content=

        {beventname:"onclick"}

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

        { content["beventtarget.id"]="ul"; }
        tapestry.bind("/event/app?component=ul&page=Home&service=directevent", content);
        };
        dojo.event.connect(dojo.byId("ul"), "onclick", tapestry, "event1675372791");});

        When i then click on the first item it outputs "list" correctly into my console.
        Reloading the page then with the submit link returns following javascript code, that causes the
        multiple events:

        dojo.addOnLoad(function(e) {
        dojo.require("tapestry.form");tapestry.form.registerForm("Form");
        tapestry.form.focusField('iteration');
        tapestry.cleanConnect(dojo.byId("ul"), "onclick", "event1675372791");
        tapestry.event1675372791=function(e){
        var content={beventname:"onclick"};
        tapestry.event.buildEventProperties(e, content);
        if (!content["beventtarget.id"]) { content["beventtarget.id"]="ul"; }

        tapestry.bind("/event/app?component=ul&page=Home&service=directevent", content);
        };
        dojo.event.connect(dojo.byId("ul"), "onclick", tapestry, "event1675372791");
        tapestry.cleanConnect(dojo.byId("list"), "onclick", "event526584677");
        tapestry.event526584677=function(e){
        var content=

        {beventname:"onclick"}

        ;
        tapestry.event.buildEventProperties(e, content);
        if (!content["beventtarget.id"]) content["beventtarget.id"]="list";
        tapestry.bind("/event/app?component=ul&page=Home&service=directevent", content);
        };
        dojo.event.connect(dojo.byId("list"), "onclick", tapestry, "event526584677");});

        For any event that was triggered an additional javascript block will be generated on any new
        page reload via the submit link. i suspect there is a place anywhere where there is some sort
        of state information where it shouldn't be. Or maybe the events are missinterpreted as additional
        @EventListener annotations. i must admit i was not able to find this specific place

        i hope this helps to reproduce the bug

        ps. sorry for being so annoying

        Show
        Kristian Marinkovic added a comment - hi jesse, i just did a clean checkout and built tapestry 4.1.2-SNAPSHOT on my local machine. After starting up tomcat i could reproduce the bug (btw. some test fail ). The javascript code of the page looks like this when first started: dojo.addOnLoad(function(e) { dojo.require("tapestry.form");tapestry.form.registerForm("Form"); tapestry.form.focusField('iteration'); tapestry.cleanConnect(dojo.byId("ul"), "onclick", "event1675372791"); tapestry.event1675372791=function(e){ var content= {beventname:"onclick"} ; tapestry.event.buildEventProperties(e, content); if (!content ["beventtarget.id"] ) { content["beventtarget.id"]="ul"; } tapestry.bind("/event/app?component=ul&page=Home&service=directevent", content); }; dojo.event.connect(dojo.byId("ul"), "onclick", tapestry, "event1675372791");}); When i then click on the first item it outputs "list" correctly into my console. Reloading the page then with the submit link returns following javascript code, that causes the multiple events: dojo.addOnLoad(function(e) { dojo.require("tapestry.form");tapestry.form.registerForm("Form"); tapestry.form.focusField('iteration'); tapestry.cleanConnect(dojo.byId("ul"), "onclick", "event1675372791"); tapestry.event1675372791=function(e){ var content={beventname:"onclick"}; tapestry.event.buildEventProperties(e, content); if (!content ["beventtarget.id"] ) { content["beventtarget.id"]="ul"; } tapestry.bind("/event/app?component=ul&page=Home&service=directevent", content); }; dojo.event.connect(dojo.byId("ul"), "onclick", tapestry, "event1675372791"); tapestry.cleanConnect(dojo.byId("list"), "onclick", "event526584677"); tapestry.event526584677=function(e){ var content= {beventname:"onclick"} ; tapestry.event.buildEventProperties(e, content); if (!content ["beventtarget.id"] ) content ["beventtarget.id"] ="list"; tapestry.bind("/event/app?component=ul&page=Home&service=directevent", content); }; dojo.event.connect(dojo.byId("list"), "onclick", tapestry, "event526584677");}); For any event that was triggered an additional javascript block will be generated on any new page reload via the submit link. i suspect there is a place anywhere where there is some sort of state information where it shouldn't be. Or maybe the events are missinterpreted as additional @EventListener annotations. i must admit i was not able to find this specific place i hope this helps to reproduce the bug ps. sorry for being so annoying
        Hide
        Jesse Kuhnert added a comment -

        Thanks for the maven2 project, certainly made it easier to look at. I can't re-produce this currently using the latest 4.1.2-SNAPSHOT version of Tapestry. Maybe it was broken before ? Either way it works now so upgrade I guess.

        Show
        Jesse Kuhnert added a comment - Thanks for the maven2 project, certainly made it easier to look at. I can't re-produce this currently using the latest 4.1.2-SNAPSHOT version of Tapestry. Maybe it was broken before ? Either way it works now so upgrade I guess.
        Hide
        Kristian Marinkovic added a comment -

        maven2 project to reproduce the bug

        Show
        Kristian Marinkovic added a comment - maven2 project to reproduce the bug

          People

          • Assignee:
            Jesse Kuhnert
            Reporter:
            Kristian Marinkovic
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development