You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mm...@apache.org on 2005/09/28 23:13:57 UTC
svn commit: r292302 - in
/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom:
autoupdatedatatable/ inputsuggestajax/ inputsuggestajax/resource/
prototype/ prototype/resource/
Author: mmarinschek
Date: Wed Sep 28 14:13:41 2005
New Revision: 292302
URL: http://svn.apache.org/viewcvs?rev=292302&view=rev
Log:
Played with JavaScript in renderers, apart from this minor changes.
Added:
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/prototype/
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/prototype/PrototypeResourceLoader.java
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/prototype/resource/
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/prototype/resource/controls.js
- copied, changed from r292168, myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputsuggestajax/resource/controls.js
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/prototype/resource/dragdrop.js
- copied, changed from r292168, myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputsuggestajax/resource/dragdrop.js
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/prototype/resource/effects.js
- copied, changed from r292168, myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputsuggestajax/resource/effects.js
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/prototype/resource/prototype.js
- copied, changed from r292168, myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputsuggestajax/resource/prototype.js
Removed:
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputsuggestajax/resource/controls.js
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputsuggestajax/resource/dragdrop.js
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputsuggestajax/resource/effects.js
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputsuggestajax/resource/prototype.js
Modified:
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/autoupdatedatatable/AutoUpdateDataTableRenderer.java
myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputsuggestajax/InputSuggestAjaxRenderer.java
Modified: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/autoupdatedatatable/AutoUpdateDataTableRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/autoupdatedatatable/AutoUpdateDataTableRenderer.java?rev=292302&r1=292301&r2=292302&view=diff
==============================================================================
--- myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/autoupdatedatatable/AutoUpdateDataTableRenderer.java (original)
+++ myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/autoupdatedatatable/AutoUpdateDataTableRenderer.java Wed Sep 28 14:13:41 2005
@@ -15,7 +15,13 @@
*/
package org.apache.myfaces.custom.autoupdatedatatable;
-import java.io.IOException;
+import org.apache.myfaces.component.html.util.AddResource;
+import org.apache.myfaces.custom.ajax.api.AjaxRenderer;
+import org.apache.myfaces.custom.prototype.PrototypeResourceLoader;
+import org.apache.myfaces.renderkit.JSFAttr;
+import org.apache.myfaces.renderkit.RendererUtils;
+import org.apache.myfaces.renderkit.html.HTML;
+import org.apache.myfaces.renderkit.html.ext.HtmlTableRenderer;
import org.apache.myfaces.util.StateUtils;
import javax.faces.application.StateManager;
@@ -23,13 +29,7 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import org.apache.myfaces.component.html.util.AddResource;
-import org.apache.myfaces.custom.ajax.api.AjaxRenderer;
-import org.apache.myfaces.custom.inputsuggestajax.InputSuggestAjaxRenderer;
-import org.apache.myfaces.renderkit.JSFAttr;
-import org.apache.myfaces.renderkit.RendererUtils;
-import org.apache.myfaces.renderkit.html.HTML;
-import org.apache.myfaces.renderkit.html.ext.HtmlTableRenderer;
+import java.io.IOException;
/**
* @author Jörg Artaker
@@ -48,9 +48,8 @@
*
* @param context FacesContext
* @param component UIComponent
- * @throws java.io.IOException
*/
- private void encodeJavascript(FacesContext context, UIComponent component) throws IOException
+ private void encodeJavascript(FacesContext context, UIComponent component)
{
// check to see if javascript has already been written (which could happen if more than one tree on the same page)
if (context.getExternalContext().getRequestMap().containsKey(JAVASCRIPT_ENCODED))
@@ -58,21 +57,11 @@
return;
}
// render javascript function for client-side toggle (it won't be used if user has opted for server-side toggle)
- ResponseWriter out = context.getResponseWriter();
String javascriptLocation = (String)component.getAttributes().get(JSFAttr.JAVASCRIPT_LOCATION);
- if (javascriptLocation == null)
- {
- AddResource.addJavaScriptToHeader(InputSuggestAjaxRenderer.class, "prototype.js", context);
- }
- else
- {
- out.startElement(HTML.SCRIPT_ELEM, null);
- out.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
- out.writeAttribute(HTML.SRC_ATTR,
- javascriptLocation + "/prototype.js", null);
- out.endElement(HTML.SCRIPT_ELEM);
- }
+ AddResource.addJavaScriptToHeader(PrototypeResourceLoader.class,
+ javascriptLocation, "prototype.js", false, context);
+
context.getExternalContext().getRequestMap().put(JAVASCRIPT_ENCODED, Boolean.TRUE);
}
Modified: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputsuggestajax/InputSuggestAjaxRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputsuggestajax/InputSuggestAjaxRenderer.java?rev=292302&r1=292301&r2=292302&view=diff
==============================================================================
--- myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputsuggestajax/InputSuggestAjaxRenderer.java (original)
+++ myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputsuggestajax/InputSuggestAjaxRenderer.java Wed Sep 28 14:13:41 2005
@@ -19,6 +19,7 @@
import org.apache.myfaces.component.html.util.AddResource;
import org.apache.myfaces.custom.ajax.api.AjaxPhaseListener;
import org.apache.myfaces.custom.ajax.api.AjaxRenderer;
+import org.apache.myfaces.custom.prototype.PrototypeResourceLoader;
import org.apache.myfaces.renderkit.JSFAttr;
import org.apache.myfaces.renderkit.RendererUtils;
import org.apache.myfaces.renderkit.html.HTML;
@@ -67,45 +68,17 @@
// render javascript function for client-side toggle (it won't be used if user has opted for server-side toggle)
ResponseWriter out = context.getResponseWriter();
String javascriptLocation = (String)component.getAttributes().get(JSFAttr.JAVASCRIPT_LOCATION);
- if (javascriptLocation == null)
- {
- AddResource.addJavaScriptToHeader(InputSuggestAjaxRenderer.class, "prototype.js", context);
- AddResource.addJavaScriptToHeader(InputSuggestAjaxRenderer.class, "effects.js", context);
- AddResource.addJavaScriptToHeader(InputSuggestAjaxRenderer.class, "dragdrop.js", context);
- AddResource.addJavaScriptToHeader(InputSuggestAjaxRenderer.class, "controls.js", context);
- AddResource.addJavaScriptToHeader(InputSuggestAjaxRenderer.class, "myFaces.js", context);
-
- if ( ((InputSuggestAjax)component).getLayout().equals("default"))
- {
- AddResource.addStyleSheet(InputSuggestAjaxRenderer.class,"defaultTheme.css",context);
- }
- }
- else
- {
- out.startElement(HTML.SCRIPT_ELEM, null);
- out.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
- out.writeAttribute(HTML.SRC_ATTR,
- javascriptLocation + "/prototype.js", null);
- out.endElement(HTML.SCRIPT_ELEM);
-
- out.startElement(HTML.SCRIPT_ELEM, null);
- out.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
- out.writeAttribute(HTML.SRC_ATTR,
- javascriptLocation + "/effects.js", null);
- out.endElement(HTML.SCRIPT_ELEM);
-
- out.startElement(HTML.SCRIPT_ELEM, null);
- out.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
- out.writeAttribute(HTML.SRC_ATTR,
- javascriptLocation + "/dragdrop.js", null);
- out.endElement(HTML.SCRIPT_ELEM);
-
- out.startElement(HTML.SCRIPT_ELEM, null);
- out.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
- out.writeAttribute(HTML.SRC_ATTR,
- javascriptLocation + "/controls.js", null);
- out.endElement(HTML.SCRIPT_ELEM);
+ String styleLocation = (String)component.getAttributes().get(JSFAttr.STYLE_LOCATION);
+ AddResource.addJavaScriptToHeader(PrototypeResourceLoader.class, javascriptLocation, "prototype.js", false, context);
+ AddResource.addJavaScriptToHeader(PrototypeResourceLoader.class, javascriptLocation, "effects.js", false, context);
+ AddResource.addJavaScriptToHeader(PrototypeResourceLoader.class, javascriptLocation, "dragdrop.js", false, context);
+ AddResource.addJavaScriptToHeader(PrototypeResourceLoader.class, javascriptLocation, "controls.js", false, context);
+ AddResource.addJavaScriptToHeader(InputSuggestAjaxRenderer.class, javascriptLocation, "myFaces.js", false, context);
+
+ if ( ((InputSuggestAjax)component).getLayout().equals("default"))
+ {
+ AddResource.addStyleSheet(InputSuggestAjaxRenderer.class,styleLocation, "defaultTheme.css",context);
}
context.getExternalContext().getRequestMap().put(JAVASCRIPT_ENCODED, Boolean.TRUE);
Added: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/prototype/PrototypeResourceLoader.java
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/prototype/PrototypeResourceLoader.java?rev=292302&view=auto
==============================================================================
--- myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/prototype/PrototypeResourceLoader.java (added)
+++ myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/prototype/PrototypeResourceLoader.java Wed Sep 28 14:13:41 2005
@@ -0,0 +1,18 @@
+/**
+ * Copyright 2004 by Irian Marinschek & Spiegl Software OEG
+ */
+package org.apache.myfaces.custom.prototype;
+
+/**This class is a mere locator object
+ * for the AddResource class to find the
+ * prototype Resources in the resources package.
+ *
+ * @author Martin Marinschek
+ * @version $Revision: $ $Date: $
+ * <p/>
+ * $Log: $
+ */
+public class PrototypeResourceLoader
+{
+ private PrototypeResourceLoader() {}
+}
Copied: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/prototype/resource/controls.js (from r292168, myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputsuggestajax/resource/controls.js)
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/prototype/resource/controls.js?p2=myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/prototype/resource/controls.js&p1=myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputsuggestajax/resource/controls.js&r1=292168&r2=292302&rev=292302&view=diff
==============================================================================
(empty)
Copied: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/prototype/resource/dragdrop.js (from r292168, myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputsuggestajax/resource/dragdrop.js)
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/prototype/resource/dragdrop.js?p2=myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/prototype/resource/dragdrop.js&p1=myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputsuggestajax/resource/dragdrop.js&r1=292168&r2=292302&rev=292302&view=diff
==============================================================================
(empty)
Copied: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/prototype/resource/effects.js (from r292168, myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputsuggestajax/resource/effects.js)
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/prototype/resource/effects.js?p2=myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/prototype/resource/effects.js&p1=myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputsuggestajax/resource/effects.js&r1=292168&r2=292302&rev=292302&view=diff
==============================================================================
(empty)
Copied: myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/prototype/resource/prototype.js (from r292168, myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputsuggestajax/resource/prototype.js)
URL: http://svn.apache.org/viewcvs/myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/prototype/resource/prototype.js?p2=myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/prototype/resource/prototype.js&p1=myfaces/sandbox/trunk/src/java/org/apache/myfaces/custom/inputsuggestajax/resource/prototype.js&r1=292168&r2=292302&rev=292302&view=diff
==============================================================================
(empty)