google-code-export / jqwicket

Automatically exported from code.google.com/p/jqwicket
1 stars 0 forks source link

Exception thrown when specifying JavaScriptResourceReference in JQContributionConfig #29

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I have just upgrade to JQWicket 0.8 and Wicket 1.5.3 and when attempting to 
deploy, the exception "url cannot be empty or null" is thrown. Below is an 
example of the Wicket init method.

JQContributionConfig config = new JQContributionConfig(new 
JavaScriptResourceReference(WicketConsole.class,"jquery-1.7.1.min.js"))
        .withJQueryUiCss(new CssResourceReference(WicketConsole.class,"jquery-ui-1.8.16.custom.css"))
        .withJQueryUiJs(new JavaScriptResourceReference(WicketConsole.class,"jquery-ui-1.8.16.custom.min.js"));

this.getComponentPreOnBeforeRenderListeners().add(new 
JQComponentOnBeforeRenderListener(config));

The issue appears to be a result of the JQContributionRenderer doing a null 
check in the determineResourcesUrll. Since all of the configurations are 
JavaScriptResourceReference's, the configuration of the CharSequence values are 
null. When this value is converted to an array on line 106, it is not a null 
value, but a CharSequence with a value of null. This causes an issue on line 
152 when the collection is iterated over. 

The solution I have found is to do a null check similar to how 
JavaScriptResourceReference's and CSSResourceReference's are doing before 
calling the renderJavascriptReference/CSS methods on lines 158/172.

Original issue reported on code.google.com by andy.bl...@gmail.com on 14 Jan 2012 at 5:44

GoogleCodeExporter commented 9 years ago
Yeah, I have the same problem ... and I think @andy solution seems right, hope 
we can the this bug fixed soon!

Original comment by hn.sgmedia on 18 Jan 2012 at 9:55

GoogleCodeExporter commented 9 years ago
Could you kindly post an example code< of how you sorted this??

Im using wicket 1.5.5 and im now wondering if it is not conflicting?

Regards

Original comment by pandre...@fnb.co.za on 3 Apr 2012 at 11:55

GoogleCodeExporter commented 9 years ago
Hi... based on the comments above, I made explicit changes to the 
JQContributionRenderer class to check for nulls in these methods:

private void renderJsResourcesUrls(IHeaderResponse response, 
Collection<CharSequence> resources) {
        for (CharSequence url : resources) {
           if (url != null)
            response.renderJavaScriptReference(determineResourcesUrl(url));
        }
    }

    private void renderJsResourcesRefs(IHeaderResponse response, Collection<JavaScriptResourceReference> resources) {
        for (JavaScriptResourceReference ref : resources) {
            if (ref != null)
                response.renderJavaScriptReference(ref);
        }
    }

    private void renderCssResourcesUrls(IHeaderResponse response, Collection<CharSequence> resources) {
        for (CharSequence url : resources) {
            if (url != null)
                 response.renderCSSReference(determineResourcesUrl(url));
        }
    }

    private void renderCssResourcesRefs(IHeaderResponse response, Collection<CssResourceReference> resources) {
        for (CssResourceReference ref : resources) {
            if (ref != null)
                response.renderCSSReference(ref);
        }
    }

Original comment by drbobdu...@gmail.com on 20 Apr 2012 at 3:09

GoogleCodeExporter commented 9 years ago
Hi guys... Here's the SOLUTION:

JQContributionConfig config = new JQContributionConfig().withDefaultJQueryUi();
getComponentPreOnBeforeRenderListeners().add(new 
JQComponentOnBeforeRenderListener(config));

Original comment by alan.damghani on 25 Jun 2012 at 10:04

GoogleCodeExporter commented 9 years ago
Hey Alan,
the solution you posted is a workaround and does not help, if you want to use 
jqwicket with local JavaScriptResourceReferences and other versions of jquery.

Is there any way to extend the JQContributionRenderer and overwrite some 
methods?

Original comment by emel.se...@gmx.de on 28 Aug 2012 at 8:08