On Wed, Jul 25, 2012 at 6:42 PM, Bertrand Guay-Paquet <[email protected]> wrote: > Here's what I have: > > /jqueryui/jquery-ui-1.8.17.custom.min.js > /myWicketMountedPage <== wicket page which references jqueryui lib > /myStaticPage.html <== a non-wicket page (static html or php or ...) which > also references jqueryui lib > > Assume all paths have "servletroot/" pre-pended so absolute urls cannot be > used. > > What I meant is that jquery ui's lib must be shared between wicket and > static (non-wicket) pages. > [see below] > > >>> Currently, I use the following code in my base page class: >>> >>> public void renderHead(IHeaderResponse response) { >>> >>> response.render(JavaScriptHeaderItem.forUrl("jqueryui/jquery-ui-1.8.17.custom.min.js")); >>> } >>> >>> "jqueryui/jquery-ui-1.8.17.custom.min.js" is always rendered as a url >>> relative to Wicket's root. I can't use a PackageResource because this >>> script >>> must be accessible by other static pages in the same server root. >> >> How using JavaScriptHeaderItem.forUrl() saves you from having >> duplicated <script>s for a resource which is loaded once by Wicket and >> additionally by static .html ? > > In the wicket pages, I only use: > response.render(JavaScriptHeaderItem.forUrl("jqueryui/jquery-ui-1.8.17.custom.min.js")); > to add the jqueryui lib which produces a <script> with a url relative to > Wicket's root. I never use both the programmatic and static html references > in the same page. > > Here is the very simple diff: > --- > a/wicket-core/src/main/java/org/apache/wicket/request/resource/ExternalUrlResourceReference.java > +++ > b/wicket-core/src/main/java/org/apache/wicket/request/resource/ExternalUrlResourceReference.java > @@ -41,13 +41,6 @@ public class ExternalUrlResourceReference extends > ResourceReference > public ExternalUrlResourceReference(final Url externalUrl) > { > super(asName(externalUrl)); > - > - if (externalUrl.isAbsolute() == false) > - { > - throw new > IllegalArgumentException(ExternalUrlResourceReference.class.getSimpleName() > + > - " can be used only with absolute urls."); > - } > - > this.externalUrl = externalUrl; > } > > In fact, it's so simple that it prompted me to ask why there is a > requirement on the absoluteness of the url. If I can find a way to use an > actual ResourceReference subclass for the jQueryUI lib, I will be able to > properly use the resource dependencies functionality. >
Since ExternalLink doesn't require absolute url I don't see reason why to not relax this too. Please file a ticket. > Bertrand -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com
