Wicket
  1. Wicket
  2. WICKET-3669

<script> element in Ajax requests is executed twice in Opera 11

    Details

      Description

      I have component with behavior which adds <script> element in Behavior.onComponentRendered() to respons. This javascript is to be processed in browser when component is rendered. This works pretty well when component is rendered during standard HTTP request. But when the same code is called from Ajax request, this script runs on browser two times!

      There is some magic in Ajax request processing in wicket-ajax.js: only for Opera and IE these <script> elements from responses are added to HTML and page <header> element as well. Comment says that this is workaround for these browsers, maybe in older versions of Opera dynamically adding element into HTML doesn't run <script> elements within, but now could be obsolete.

      1. testcase-WICKET-3669-second.tar.gz
        8 kB
        Martin Schayna
      2. testcase-WICKET-3669.tar.gz
        8 kB
        Martin Schayna

        Activity

        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        5d 4h 17m 1 Martin Grigorov 10/May/11 15:48
        Resolved Resolved Reopened Reopened
        64d 2h 49m 1 Martin Grigorov 13/Jul/11 18:37
        Reopened Reopened Resolved Resolved
        159d 19h 51m 1 Martin Grigorov 20/Dec/11 13:29
        Martin Grigorov made changes -
        Status Reopened [ 4 ] Resolved [ 5 ]
        Fix Version/s 6.0.0 [ 12315431 ]
        Fix Version/s 1.4.20 [ 12318545 ]
        Resolution Fixed [ 1 ]
        Hide
        Martin Grigorov added a comment -

        Fixed with the usage of JQuery to replace the DOM.
        Tested with Opera 11.60 on Ubuntu.

        Show
        Martin Grigorov added a comment - Fixed with the usage of JQuery to replace the DOM. Tested with Opera 11.60 on Ubuntu.
        Igor Vaynberg made changes -
        Fix Version/s 1.4.20 [ 12318545 ]
        Fix Version/s 1.4.19 [ 12317570 ]
        Hide
        Martin Schayna added a comment -

        There are no solution out there. Maybe fix for 1.4.x can be unnecessary, but the same fix for 1.5 doesn't work...

        Show
        Martin Schayna added a comment - There are no solution out there. Maybe fix for 1.4.x can be unnecessary, but the same fix for 1.5 doesn't work...
        Jeremy Thomerson made changes -
        Fix Version/s 1.4.19 [ 12317570 ]
        Fix Version/s 1.4.18 [ 12316329 ]
        Martin Grigorov made changes -
        Resolution Fixed [ 1 ]
        Status Resolved [ 5 ] Reopened [ 4 ]
        Hide
        Martin Schayna added a comment -

        OK, I see that my simple "fix" doesn't work in Opeara 9, hm.

        I upload second test case right now, it demonstrates where your first fix failed. I hope it should be resolved in Wicket 1.4. Thanks for your support.

        Show
        Martin Schayna added a comment - OK, I see that my simple "fix" doesn't work in Opeara 9, hm. I upload second test case right now, it demonstrates where your first fix failed. I hope it should be resolved in Wicket 1.4. Thanks for your support.
        Martin Schayna made changes -
        Attachment testcase-WICKET-3669-second.tar.gz [ 12486323 ]
        Hide
        Martin Schayna added a comment -

        Second test case, where first fix won't work.

        Show
        Martin Schayna added a comment - Second test case, where first fix won't work.
        Hide
        Martin Grigorov added a comment -

        Which second case you mean ?

        We know that Opera 11 is not Opera 9. The same is valid for Safari 5 which is treated as Safari 3.
        If we do your "fix" then some user of Opera 9/10 may complain that it doesn't work ...
        We have plans to use JQuery for the functionality needed by wicket-ajax.js so hopefully this will solve all such issues. But this is planned for Wicket 1.6/1.7.

        Show
        Martin Grigorov added a comment - Which second case you mean ? We know that Opera 11 is not Opera 9. The same is valid for Safari 5 which is treated as Safari 3. If we do your "fix" then some user of Opera 9/10 may complain that it doesn't work ... We have plans to use JQuery for the functionality needed by wicket-ajax.js so hopefully this will solve all such issues. But this is planned for Wicket 1.6/1.7.
        Hide
        Martin Schayna added a comment -

        I'm afraid this ticket must be reopened.

        Fix works only for components which has <script> element on its first level (as seen in first test case). When component with script behavior is added to another component (Panel e.g.) and this parent component is changed in AJAX request, script is executed twice in browser again. See my second test case.

        I have tried this simple solution: in replaceOuterHtml() method in wicket-ajax.js comment out test for Opera browser, so in this case is executed same code as in Gecko browsers. It works for me in all of my real cases (pretty large application which heavily uses Wicket). It seems like modern Opera versions are more compatible with Gecko than older versions.

            if (Wicket.Browser.isIE()) {  //-- don't do this for Opera  || Wicket.Browser.isOpera()) {		
            	Wicket.replaceOuterHtmlIE(element, text);				
            } else if (Wicket.Browser.isSafari() ) {
            	Wicket.replaceOuterHtmlSafari(element, text);    	
            } else /* GECKO */ {
               ...
        
        Show
        Martin Schayna added a comment - I'm afraid this ticket must be reopened. Fix works only for components which has <script> element on its first level (as seen in first test case). When component with script behavior is added to another component (Panel e.g.) and this parent component is changed in AJAX request, script is executed twice in browser again. See my second test case. I have tried this simple solution: in replaceOuterHtml() method in wicket-ajax.js comment out test for Opera browser, so in this case is executed same code as in Gecko browsers. It works for me in all of my real cases (pretty large application which heavily uses Wicket). It seems like modern Opera versions are more compatible with Gecko than older versions. if (Wicket.Browser.isIE()) { //-- don't do this for Opera || Wicket.Browser.isOpera()) { Wicket.replaceOuterHtmlIE(element, text); } else if (Wicket.Browser.isSafari() ) { Wicket.replaceOuterHtmlSafari(element, text); } else /* GECKO */ { ...
        Martin Grigorov made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Assignee Martin Grigorov [ mgrigorov ]
        Fix Version/s 1.4.18 [ 12316329 ]
        Fix Version/s 1.5-RC5 [ 12316423 ]
        Resolution Fixed [ 1 ]
        Hide
        Martin Grigorov added a comment -

        Fixed.
        Tested on FF4, Chrome 12, IE8 and Opera 11

        Show
        Martin Grigorov added a comment - Fixed. Tested on FF4, Chrome 12, IE8 and Opera 11
        Martin Schayna made changes -
        Field Original Value New Value
        Attachment testcase-WICKET-3669.tar.gz [ 12478262 ]
        Hide
        Martin Schayna added a comment -

        quickstart for WICKET-3669

        Opera 11 shows alerts two times with same number

        Show
        Martin Schayna added a comment - quickstart for WICKET-3669 Opera 11 shows alerts two times with same number
        Martin Schayna created issue -

          People

          • Assignee:
            Martin Grigorov
            Reporter:
            Martin Schayna
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development