You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Steven Haines <ly...@yahoo.com> on 2010/04/06 15:31:58 UTC

Build custom JavaScript

For my application I need to dynamically generate JavaScript, which can either be in its own file or even added to my HTML document. I'll handle the generation of the JavaScript, but does anyone have any good strategies for injecting it into a web page or even generating a JavaScript file with Wicket?

Thanks
Steve


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


RE: Build custom JavaScript

Posted by Craig McIlwee <cr...@openroadsconsulting.com>.
If the javascript will change often then it's probably best to include it directly into the <head> of the page, otherwise it's just another HTTP request that probably won't be cachable.  So to put something in the <head>, you can try a StringHeaderContributor or implement IHeaderContributor.

If you really want to use a file, I guess you could probably use JavaScriptResourceReference.  The Resource itself would be WebResource or one of its subclasses and would return a StringResourceStream that wraps your generated JS.  This is just a guess though since I haven't actually tried it.

Craig

-----Original Message-----
From: Steven Haines [mailto:lygado@yahoo.com] 
Sent: Tuesday, April 06, 2010 9:32 AM
To: Wicket User List
Subject: Build custom JavaScript

For my application I need to dynamically generate JavaScript, which can either be in its own file or even added to my HTML document. I'll handle the generation of the JavaScript, but does anyone have any good strategies for injecting it into a web page or even generating a JavaScript file with Wicket?

Thanks
Steve


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org