Author: ehillenius
Date: Fri Aug 3 16:29:06 2007
New Revision: 562614
URL: http://svn.apache.org/viewvc?view=rev&rev=562614
Log:
bootstrap loading the YUI deps
Modified:
wicket/trunk/jdk-1.4/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/YuiLib.java
wicket/trunk/jdk-1.4/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePicker.java
Modified:
wicket/trunk/jdk-1.4/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/YuiLib.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/YuiLib.java?view=diff&rev=562614&r1=562613&r2=562614
==============================================================================
---
wicket/trunk/jdk-1.4/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/YuiLib.java
(original)
+++
wicket/trunk/jdk-1.4/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/YuiLib.java
Fri Aug 3 16:29:06 2007
@@ -17,15 +17,40 @@
package org.apache.wicket.extensions.yui;
import org.apache.wicket.IClusterable;
+import org.apache.wicket.markup.html.IHeaderResponse;
+import org.apache.wicket.markup.html.resources.JavascriptResourceReference;
/**
- * Just a trick to serve as a reference for YUI includes.
+ * Use the [EMAIL PROTECTED] #load(IHeaderResponse, boolean)} method to
initialize the YUI
+ * library using the YUI loader. It is OK to call this multiple times.
*
* @author eelcohillenius
*/
public final class YuiLib implements IClusterable
{
private static final long serialVersionUID = 1L;
+
+ /**
+ * Load the YUI loader script. After that, you can declare YUI
dependencies
+ * using YAHOO.util.YUILoader.
+ *
+ * @param response
+ * header response
+ * @param configureBasePath
+ * whether to globally configure YUI's base path to be
relative
+ * to this directory
+ */
+ // TODO see
http://tech.groups.yahoo.com/group/ydn-javascript/message/16209
+ public static void load(IHeaderResponse response, boolean
configureBasePath)
+ {
+ if (configureBasePath)
+ {
+ response.renderJavascript("YAHOO_config = { load: {
base: 'resources/"
+ + YuiLib.class.getName() + "/'} } ",
"YAHOO_config");
+ }
+ response.renderJavascriptReference(new
JavascriptResourceReference(YuiLib.class,
+ "yuiloader-beta.js"));
+ }
/**
* Prevent construction.
Modified:
wicket/trunk/jdk-1.4/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePicker.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePicker.java?view=diff&rev=562614&r1=562613&r2=562614
==============================================================================
---
wicket/trunk/jdk-1.4/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePicker.java
(original)
+++
wicket/trunk/jdk-1.4/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePicker.java
Fri Aug 3 16:29:06 2007
@@ -147,9 +147,7 @@
*/
public void renderHead(IHeaderResponse response)
{
- // add YUILoader
- response.renderJavascriptReference(new
JavascriptResourceReference(YuiLib.class,
- "yuiloader-beta.js"));
+ YuiLib.load(response, getConfigureYUIBasePath());
// variables for the initialization script
Map variables = new HashMap();
@@ -353,7 +351,6 @@
return (String[])l.toArray(new String[l.size()]);
}
-
/**
* Gets the id of the component that the calendar widget will get
attached
* to.
@@ -363,6 +360,17 @@
protected final String getComponentMarkupId()
{
return component.getMarkupId();
+ }
+
+
+ /**
+ * @return if true, the base path for all YUI components will be set to
+ * /resources/org.apache.wicket.extensions.yui.YuiLib/. True by
+ * default.
+ */
+ protected boolean getConfigureYUIBasePath()
+ {
+ return true;
}
/**