It can be accomplished by the component hierarchy, by knowing that parent
components' references are added first or in other words renderHead is
invoked earlier.

So you may have a:

class AbstractPrototypScriptaculousBehaviour extends AbstractBehaviour {
  renderHead( response ){
    super.renderHead( response  );
    response.renderJavascrtReference( new JavascriptResourceReference(
this.getClass(), "js/prototype.js" ), "prototype" );
    response.renderJavascrtReference( new JavascriptResourceReference(
this.getClass(), "js/scriptaculous.js?load=effects,builder" ),
"scriptaculous" );
  }
}

class LightBoxBehaviour extends AbstractPrototypScriptaculousBehaviour {
  renderHead( response ){
    super.renderHead( response  );
    response.renderJavascrtReference( new JavascriptResourceReference(
this.getClass(), "lightbox.js" ), "lightbox" );
  }
}


Žilvinas Vilutis

Mobile:   (+370) 652 38353
E-mail:   [email protected]


On Mon, May 17, 2010 at 1:03 PM, Ralf Eichinger
<[email protected]>wrote:

> How can I ensure that "lightbox" JavaScriptReference (see below) is
> loaded after the two HeaderContributions (prototype and scriptaculous)?
>
> - Headercontributions:
> add(JavascriptPackageResource.getHeaderContribution(this.getClass(),
>                                "js/prototype.js"));
> add(JavascriptPackageResource.getHeaderContribution(this.getClass(),
>
>  "js/scriptaculous.js?load=effects,builder"));
>
> - JavaScriptReference:
> add(new JavaScriptReference("lightbox", new
> TextTemplateResourceReference(this.getClass(), "js/lightbox.js",
> "text/javascript", new LoadableDetachableModel<Map<String, Object>>()
> {...}})));
>
> and in HTML of this Panel:
> <wicket:head>
> <script wicket:id="lightbox" src="#" language="JavaScript"></script>
> </wicket:head>
>
> The result is always this order in the HTML:
> <script wicket:id="lightbox"
> src="resources/LightBox2Panel/js/lightbox.js" language="JavaScript"
> type="text/javascript"></script>
> <script type="text/javascript"
> src="resources/LightBox2Panel/js/prototype.js"></script>
> <script type="text/javascript"
> src="resources/LightBox2Panel/js/scriptaculous.js?load=effects,builder"></script>
>
> I already tried to load the HeaderContributions as JavaScriptReference,
> too, and
> defining the order in the Panel-HTML-template, but then I can not pass the
> URL-params to scriptaculous.js...
>
> Any ideas?
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to