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

Erik van Oosten commented on WICKET-1746:
-----------------------------------------

As a workaround, add the following behavior to your page (javascript based on 
wicket 1.3.4):

private static class WicketAjaxRelativePathFixBehaviour extends AbstractBehavior
{
        private static final long serialVersionUID = 1L;

        @Override
        public void renderHead(IHeaderResponse response)
        {
                String script = "if (Wicket && Wicket.Ajax && 
Wicket.Ajax.Request) {"+
                                "Wicket.Ajax.Request.prototype.doGet = 
function() {" + 
                                "       if (this.precondition()) {" + 
                                "               this.transport = 
Wicket.Ajax.getTransport();" + 
                                "               var url = this.createUrl();" + 
                                "               this.log(\"GET\", url);" + 
                                "               
Wicket.Ajax.invokePreCallHandlers();" + 
                                "               var t = this.transport;" + 
                                "               if (t != null) {" + 
                                "                       t.open(\"GET\", url, 
this.async);" + 
                                "                       t.onreadystatechange = 
this.stateChangeCallback.bind(this);" + 
                                "                       /*set a special flag to 
allow server distinguish between ajax and non-ajax requests*/" + 
                                "                       
t.setRequestHeader(\"Wicket-Ajax\", \"true\");" + 
                                "                       
t.setRequestHeader(\"Wicket-FocusedElementId\", Wicket.Focus.lastFocusId || 
\"\");" + 
                                "                       
t.setRequestHeader(\"Accept\", \"text/xml\");" + 
                                "                       t.send(null);" + 
                                "                       return true;" + 
                                "               } else {" + 
                                "                       this.failure();" + 
                                "               return false;" + 
                                "               }" + 
                                "       } else {" + 
                                "               Wicket.Log.info(\"Ajax GET 
stopped because of precondition check, url:\" + this.url);" + 
                                "               this.done();" + 
                                "               return true;" + 
                                "       }" + 
                                "}}";
                response.renderOnDomReadyJavascript(script);
        }
}


> gecko: ajax javascript reference rendering problem
> --------------------------------------------------
>
>                 Key: WICKET-1746
>                 URL: https://issues.apache.org/jira/browse/WICKET-1746
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.4-M2
>            Reporter: Jan Loose
>            Assignee: Matej Knopp
>             Fix For: 1.3.5, 1.4-M4
>
>
> Hi,
> i tried render the javascript as:
> public void renderHead(IHeaderResponse response) {
>   response.renderJavascriptReference(contextPath + "js/test.js");
> }
> The test.js is in webapp/js/test.js (out of classpath). All works greatly in 
> Opera but in FF (gecko) is there a problem in wicket-ajax.js (the code is 
> form trunk version): 
> 836: if (Wicket.Browser.isGecko()) {
> 837:     var href = document.location.href;
> 838:     var lastIndexOf = href.lastIndexOf('/');
> 839:         if (lastIndexOf > 0)
> 840:         {
> 841:                 url = href.substring(0,lastIndexOf+1) + url;
> 842:        }
> 843:}
> Why is there this fix/workaround? This works only for relative path but for 
> absolute is this code broken.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to