is it possible to include script resources using the HeaderContributor above the WebPage component script references
Hello, I would like for the script included using a HeaderContributor to be above script references within the WebPage component head node. Is this possible. The reason I would like to do this is because I would like to be able to reference code from the script file which is included using the HeaderContributor. For example: --- Application class --- // inside init method addComponentInstantiationListener(new IComponentInstantiationListener() { public void onInstantiation(Component component) { if (component instanceof WebPage) { component.add(new HeaderContributor(new IHeaderContributor() { public void renderHead(IHeaderResponse response) { response.renderJavascriptReference(new JavascriptResourceReference(MyReferenceClass.class, scripts/example.js)); } })); } } }); // WebPage component template head script type=text/javascript ... // I can't reference anything from the scripts/example.js because the source reference appears below this in the rendered output /script /head By the way, please tell me if this is bad code and there is a better way as I am very new to Wicket. All code criticism is welcomed :) Thanks. Joe
Re: is it possible to include script resources using the HeaderContributor above the WebPage component script references
Joe, an diferent option is create a custom WebPage with all needed resources to serve as super class for all web pages class of your application. Html for super class: html head wicket:link script type=text/javascript src=scripts/example.js/script /wicket:link /head body wicket:child / /body /html and for subclasses head /head body wicket:extend !-- page code -- /wicket:extend /body /html On Mon, Aug 31, 2009 at 9:08 AM, Joe Hudson joe.hud...@clear2pay.comwrote: Hello, I would like for the script included using a HeaderContributor to be above script references within the WebPage component head node. Is this possible. The reason I would like to do this is because I would like to be able to reference code from the script file which is included using the HeaderContributor. For example: --- Application class --- // inside init method addComponentInstantiationListener(new IComponentInstantiationListener() { public void onInstantiation(Component component) { if (component instanceof WebPage) { component.add(new HeaderContributor(new IHeaderContributor() { public void renderHead(IHeaderResponse response) { response.renderJavascriptReference(new JavascriptResourceReference(MyReferenceClass.class, scripts/example.js)); } })); } } }); // WebPage component template head script type=text/javascript ... // I can't reference anything from the scripts/example.js because the source reference appears below this in the rendered output /script /head By the way, please tell me if this is bad code and there is a better way as I am very new to Wicket. All code criticism is welcomed :) Thanks. Joe
Re: is it possible to include script resources using the HeaderContributor above the WebPage component script references
This could be helpful for you for first step: http://cwiki.apache.org/WICKET/markup-inheritance.html Regards, Peter Joe Hudson írta: Hello, I would like for the script included using a HeaderContributor to be above script references within the WebPage component head node. Is this possible. The reason I would like to do this is because I would like to be able to reference code from the script file which is included using the HeaderContributor. For example: --- Application class --- // inside init method addComponentInstantiationListener(new IComponentInstantiationListener() { public void onInstantiation(Component component) { if (component instanceof WebPage) { component.add(new HeaderContributor(new IHeaderContributor() { public void renderHead(IHeaderResponse response) { response.renderJavascriptReference(new JavascriptResourceReference(MyReferenceClass.class, scripts/example.js)); } })); } } }); // WebPage component template head script type=text/javascript ... // I can't reference anything from the scripts/example.js because the source reference appears below this in the rendered output /script /head By the way, please tell me if this is bad code and there is a better way as I am very new to Wicket. All code criticism is welcomed :) Thanks. Joe - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org