[ 
https://issues.apache.org/jira/browse/WICKET-3420?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12996310#comment-12996310
 ] 

Martin Grigorov commented on WICKET-3420:
-----------------------------------------

With r1071930 (trunk0 and r1071931 (1.4.x) I added logic to log an error with 
the message provided by the Javascript engine about the problem.
Tested with Firefox 3.6, Chrome 10.x and Opera 11. FF3 gives the best 
description of the problem. IE uses ActiveXObject to parse XML and has its own 
logic to log errors.

I think Wicket cannot do more here. Even my IDE marks this line as JS error. 
The best solution is to wrap the JS code in HTML comments:
<script>
<!--
  if (a < 0) {...}
-->
</script>

This is proven to work with the years.

If anyone else has better solution please share, otherwise I think we can close 
the ticket as "Won't fix",

> javascript with a less than character ("<") fails to execute when added 
> through a header contribution in ajax response
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: WICKET-3420
>                 URL: https://issues.apache.org/jira/browse/WICKET-3420
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.4.15
>         Environment: Validated this bug on my dev environment: Windows 7 64 
> bit using Firefox 4.0beta10 and Chrome 8.
>            Reporter: Randy Schnedler
>            Assignee: Martin Grigorov
>            Priority: Minor
>              Labels: ajax, header-contribution, javascript, wicket-ajax.js
>
> This is adapted from a wicket users post I made (links are to the same thread 
> in two archive systems):
> http://markmail.org/search/?q=wicket%20users%20wicket-ajax.js#query:wicket%20users%20wicket-ajax.js+page:1+mid:rfts3ar3upffhbbt+state:results
> http://mail-archives.apache.org/mod_mbox/wicket-users/201102.mbox/%3CAANLkTi=ekmta0rna+gyje-cqwmkcxrlsjp+z8jwv-...@mail.gmail.com%3E
> The problem:  I have a panel with this:
>     <wicket:head>
>       <script>
>               if (someVariable < 0) {
>                       someVariable = 0;               
>               }
>       </script>
>     </wicket:head>
> This script fails to execute when the panel is loaded by ajax.  If I replace 
> the less than character "<" with equals "==", then it executes (but of 
> course, this is not what I need).
> I tested this in Firefox 4.0b10 and Chrome 8.
> After some debugging, it seems to me that this needs to be corrected in 
> wicket-ajax.js. The header contribution is sent to the browser inside of a 
> CDATA section so the "<" character arrives to javascript intact. However, in 
> parsing the script tag, the "<" seems to signal the beginning of an HTML tag 
> that then is considered malformed.
> Possible workarounds for apps:
>  - Invert the logic so a greater-than is used. In my example, this would be: 
> "if (0 > someVariable) {"
>  - Put the code into a separate JS file (the downside is it requires another 
> network hop from the browser)
>  - Embed the script in <wicket:panel> rather than <wicket:head> (the 
> disadvantage is the script will be re-sent with the panel content when the 
> panel is re-used on the same page)

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to