On Mon, Feb 14, 2011 at 12:11 AM, Zilvinas Vilutis <[email protected]>wrote:
>
> Hi Jeremy,
>
> Thanks for the implementation ( I've found that you're the author of most
> of
> the files :) ) - it will be really useful in the future.
>
> 1st problem I ran into - no usage example in Javadocs :) However, mailing
> list helped!
> ... after that
> I've found that one of the core WiQuery classes renders javascript with
> response.renderString method (
> org.wicketstuff.jquery.JQueryBehavior.renderHead(IHeaderResponse) ):
>
Hmm, yeah, renderString doesn't give us any metadata to work with to realize
it's JS and therefore filter it. It could be anything, or any combination
of things. I think you should ask the WiQuery guys to change their usage to
use renderJavascript so that you can use this with it.
> @Override
> public void renderHead(IHeaderResponse response) {
> try {
> super.renderHead(response);
> if(getIncludeJQueryJS(response)) {
> response.renderJavascriptReference(JQUERY_JS);
> if
> (Application.DEVELOPMENT.equals(Application.get().getConfigurationType()))
> {
> response.renderJavascriptReference(JQUERY_DEBUG_JS);
> }
> }
> CharSequence script = getOnReadyScript();
> if ((script != null) && (script.length() > 0)) {
> StringBuilder builder = new StringBuilder();
> builder.append("<script
> type=\"text/javascript\">\n$(document).ready(function(){\n");
> builder.append(script);
> builder.append("\n});</script>");
> response.renderString(builder.toString());
> }
> } catch (RuntimeException exc) {
> throw exc;
> } catch (Exception exc) {
> throw new RuntimeException("wrap: " + exc.getMessage(), exc);
> }
> }
>
>
> Which is not being filtered and gets into header - which causes the
> "$('document')" string to be not valid before jquery.js was loaded.
>
> Basic features looks good and definitely a good start!
>
> Probably I'll need more examples how to use
> "AbstractResourceDependentResourceReference" to create JS Reference
> dependencies and make sure the order is all right.
>
Take a look at the examples and start a thread for questions if you have
them.
--
Jeremy Thomerson
http://wickettraining.com
*Need a CMS for Wicket? Use Brix! http://brixcms.org*