Author: nbelaevski
Date: 2007-06-28 15:04:23 -0400 (Thu, 28 Jun 2007)
New Revision: 1380
Removed:
trunk/richfaces/drag-drop/src/main/templates/org/richfaces/htmlDragIndicatorView.jspx
Modified:
trunk/richfaces/common/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java
trunk/richfaces/drag-drop/src/main/config/component/dragIndicator.xml
trunk/richfaces/drag-drop/src/main/java/org/richfaces/renderkit/DnDParametersEncoder.java
trunk/richfaces/drag-drop/src/main/java/org/richfaces/renderkit/DragIndicatorRendererBase.java
trunk/richfaces/drag-drop/src/main/resources/org/richfaces/renderkit/html/scripts/drag-indicator.js
Log:
Default dragIndicator view "JSONized" to get rid of own renderer. API fine
refactored :)
Modified:
trunk/richfaces/common/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java
===================================================================
---
trunk/richfaces/common/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java 2007-06-28
19:01:12 UTC (rev 1379)
+++
trunk/richfaces/common/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java 2007-06-28
19:04:23 UTC (rev 1380)
@@ -7,7 +7,6 @@
import java.io.InputStream;
import java.io.StringReader;
import java.io.StringWriter;
-import java.util.Iterator;
import java.util.Properties;
import javax.faces.component.UIComponent;
@@ -24,7 +23,6 @@
import org.ajax4jsf.framework.ajax.xmlfilter.tidy.TidyParser;
import org.ajax4jsf.framework.ajax.xmlfilter.tidy.TidyXMLFilter;
import org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase;
-import org.ajax4jsf.framework.renderer.RendererBase;
import org.richfaces.json.JSContentHandler;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
@@ -95,53 +93,18 @@
writer.write("];\n");
}
- private void encodeComponent(FacesContext context, UIComponent component, RendererBase
rendererBase) throws IOException {
- if (!component.isRendered()) {
- return;
- }
-
- rendererBase.encodeBegin(context, component);
- if (component.getRendersChildren() || rendererBase.getRendersChildren()) {
- rendererBase.encodeChildren(context, component);
- } else {
- if (component.getChildCount() > 0) {
- for (Iterator it = component.getChildren().iterator(); it.hasNext();) {
- UIComponent child = (UIComponent) it.next();
- renderChild(context, child);
- }
- }
- }
- rendererBase.encodeEnd(context, component);
- }
-
- protected void writeScriptBody(FacesContext context, UIComponent component, boolean
children,
- RendererBase rendererBase)
+ protected void writeScriptBody(FacesContext context, UIComponent component, boolean
children)
throws IOException {
ResponseWriter writer = context.getResponseWriter();
StringWriter dumpingWriter = new StringWriter();
ResponseWriter clonedWriter = writer.cloneWithWriter(dumpingWriter);
context.setResponseWriter(clonedWriter);
try {
-
- if (rendererBase == null) {
- if (children) {
- this.renderChildren(context, component);
- } else {
- this.renderChild(context, component);
- }
+ if (children) {
+ this.renderChildren(context, component);
} else {
- if (children) {
- if (component.getChildCount() > 0)
- for (Iterator it = component.getChildren().iterator(); it.hasNext();) {
- UIComponent child = (UIComponent) it.next();
-
- encodeComponent(context, child, rendererBase);
- }
- } else {
- encodeComponent(context, component, rendererBase);
- }
+ this.renderChild(context, component);
}
-
} finally {
clonedWriter.flush();
context.setResponseWriter(writer);
@@ -155,7 +118,7 @@
ResponseWriter writer = context.getResponseWriter();
writer.startElement("script", component);
writer.write("var evaluator = ");
- writeScriptBody(context, component, true, null);
+ writeScriptBody(context, component, true);
writer.write("new Insertion.Top($('" + component.getClientId(context) +
"'), evaluator.invoke('getContent', window).join(''));");
writer.endElement("script");
}
Modified: trunk/richfaces/drag-drop/src/main/config/component/dragIndicator.xml
===================================================================
--- trunk/richfaces/drag-drop/src/main/config/component/dragIndicator.xml 2007-06-28
19:01:12 UTC (rev 1379)
+++ trunk/richfaces/drag-drop/src/main/config/component/dragIndicator.xml 2007-06-28
19:04:23 UTC (rev 1380)
@@ -48,7 +48,4 @@
<description>Corresponds to the HTML class attribute and
added to an indicator when a drop is rejected</description>
</property>
</component>
- <renderer generate="true">
- <template>org/richfaces/htmlDragIndicatorView.jspx</template>
- </renderer>
</components>
Modified:
trunk/richfaces/drag-drop/src/main/java/org/richfaces/renderkit/DnDParametersEncoder.java
===================================================================
---
trunk/richfaces/drag-drop/src/main/java/org/richfaces/renderkit/DnDParametersEncoder.java 2007-06-28
19:01:12 UTC (rev 1379)
+++
trunk/richfaces/drag-drop/src/main/java/org/richfaces/renderkit/DnDParametersEncoder.java 2007-06-28
19:04:23 UTC (rev 1380)
@@ -146,7 +146,7 @@
exception.initCause(e.getCause());
throw exception;
}
-
+
return merged.toString();
}
@@ -218,16 +218,17 @@
if (dndParams != null) {
if (dndParam.isRendered()) {
- if (dndParam.getChildCount() == 0) {
- dndParams.put(dndParam.getName(), dndParam.getValue());
- } else {
- List paramChildren = dndParam.getChildren();
- ResponseWriter responseWriter = context.getResponseWriter();
- StringWriter dumpWriter = new StringWriter();
+ ResponseWriter responseWriter = context.getResponseWriter();
+ StringWriter dumpWriter = new StringWriter();
- try {
- context.setResponseWriter(responseWriter.cloneWithWriter(dumpWriter));
+ try {
+ context.setResponseWriter(responseWriter.cloneWithWriter(dumpWriter));
+ if (dndParam.getChildCount() == 0) {
+ context.getResponseWriter().writeText(dndParam.getValue(), null);
+ } else {
+ List paramChildren = dndParam.getChildren();
+
for (Iterator paramIterator = paramChildren
.iterator(); paramIterator.hasNext();) {
@@ -235,16 +236,15 @@
renderChild(context, paramChild);
}
-
- context.getResponseWriter().flush();
- } finally {
- context.setResponseWriter(responseWriter);
}
- String childContent = dumpWriter.getBuffer().toString();
+ context.getResponseWriter().flush();
+ } finally {
+ context.setResponseWriter(responseWriter);
+ }
- dndParams.put(dndParam.getName(), childContent);
- }
+ String childContent = dumpWriter.getBuffer().toString();
+ dndParams.put(dndParam.getName(), childContent);
}
}
}
Modified:
trunk/richfaces/drag-drop/src/main/java/org/richfaces/renderkit/DragIndicatorRendererBase.java
===================================================================
---
trunk/richfaces/drag-drop/src/main/java/org/richfaces/renderkit/DragIndicatorRendererBase.java 2007-06-28
19:01:12 UTC (rev 1379)
+++
trunk/richfaces/drag-drop/src/main/java/org/richfaces/renderkit/DragIndicatorRendererBase.java 2007-06-28
19:04:23 UTC (rev 1380)
@@ -26,12 +26,10 @@
import java.util.Collection;
import java.util.Iterator;
-import javax.faces.FacesException;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import org.ajax4jsf.framework.renderer.RendererBase;
import org.richfaces.component.UIDragIndicator;
import org.richfaces.component.nsutils.NSUtils;
import org.richfaces.org.apache.commons.lang.StringEscapeUtils;
@@ -44,7 +42,6 @@
public class DragIndicatorRendererBase extends TemplateEncoderRendererBase {
public static final String ACCEPT_CLASS = "acceptClass";
public static final String REJECT_CLASS = "rejectClass";
- public static final String RENDERER_TYPE =
"com.exadel.jsf.renderer.DropIndicatorRenderer";
public static final String ACCEPT = "accept";
public static final String DEFAULT = "default";
@@ -66,24 +63,6 @@
FACETS_PREDEFINED.add(MULTI);
}
- private RendererBase dragIndicatorViewRenderer = null;
-
- private synchronized RendererBase getViewRenderer() {
- if (dragIndicatorViewRenderer == null) {
- try {
- dragIndicatorViewRenderer = (RendererBase)
Class.forName("org.richfaces.renderkit.html.DragIndicatorViewRenderer").newInstance();
- } catch (InstantiationException e) {
- throw new FacesException(e);
- } catch (IllegalAccessException e) {
- throw new FacesException(e);
- } catch (ClassNotFoundException e) {
- throw new FacesException(e);
- }
- }
-
- return dragIndicatorViewRenderer;
- }
-
public DragIndicatorRendererBase() {
super();
}
@@ -153,9 +132,9 @@
responseWriter.write("elt.indicatorTemplates['" + facetName +
"'] = ");
if (facet != null && facet.isRendered()) {
- writeScriptBody(context, facet, false, null);
+ writeScriptBody(context, facet, false);
} else {
- writeScriptBody(context, component, false, getViewRenderer());
+ responseWriter.write(" DefaultDragIndicatorView;");
}
}
Modified:
trunk/richfaces/drag-drop/src/main/resources/org/richfaces/renderkit/html/scripts/drag-indicator.js
===================================================================
---
trunk/richfaces/drag-drop/src/main/resources/org/richfaces/renderkit/html/scripts/drag-indicator.js 2007-06-28
19:01:12 UTC (rev 1379)
+++
trunk/richfaces/drag-drop/src/main/resources/org/richfaces/renderkit/html/scripts/drag-indicator.js 2007-06-28
19:04:23 UTC (rev 1380)
@@ -113,3 +113,66 @@
elt.ils_rejectClass = rejectClass;
}
+// <table border="0" cellpadding="3" cellspacing="0"
class="drgind_internal" style="height : 100%">
+// <tr>
+// <td class="drgind_marker">
+// {marker}
+// </td>
+// <td class="drgind_text">
+// <div class="drgind_wordcut drgind_text_content">
+// {label}
+// </div>
+// </td>
+// </tr>
+// </table>
+// <div class="drgind_shadow" />
+DefaultDragIndicatorView =
+[
+ new E('table',
+ {
+ 'style':'height : 100%',
+ 'className':'drgind_internal',
+ 'cellspacing':'0',
+ 'cellpadding':'3',
+ 'border':'0'
+ },
+ [
+ new E('tbody',{},
+ [
+ new E('tr',{},
+ [
+ new E('td',
+ {
+ 'className':'drgind_marker'
+ },
+ [
+ new ET(function (context) { return Richfaces.eval("marker",
context)})
+ ]
+ ),
+ new E('td',
+ {
+ 'className':'drgind_text'
+ },
+ [
+ new E('div',
+ {
+ 'className':'drgind_wordcut drgind_text_content'
+ },
+ [
+ new ET(function (context) { return Richfaces.eval("label",
context)})
+ ]
+ )
+ ]
+ )
+ ]
+ )
+ ]
+ )
+ ]
+ ),
+ new E('div',
+ {
+ 'className':'drgind_shadow'
+ }
+ )
+];
Deleted:
trunk/richfaces/drag-drop/src/main/templates/org/richfaces/htmlDragIndicatorView.jspx
===================================================================
---
trunk/richfaces/drag-drop/src/main/templates/org/richfaces/htmlDragIndicatorView.jspx 2007-06-28
19:01:12 UTC (rev 1379)
+++
trunk/richfaces/drag-drop/src/main/templates/org/richfaces/htmlDragIndicatorView.jspx 2007-06-28
19:04:23 UTC (rev 1380)
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<f:root
xmlns:f="http://jsf.exadel.com/template"
-
xmlns:c="http://java.sun.com/jsf/core"
-
xmlns:ui="http://jsf.exadel.com/ui"
-
xmlns:vcp="http://jsf.exadel.com/vcp"
-
xmlns:u="http://jsf.exadel.com/util"
-
xmlns:x="http://jsf.exadel.com/mock"
-
xmlns:h="http://jsf.exadel.com/header"
- baseclass="org.ajax4jsf.framework.renderer.RendererBase"
- class="org.richfaces.renderkit.html.DragIndicatorViewRenderer"
- component="org.richfaces.component.UIDragIndicator"
-
xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0">
-
- <table border="0" cellpadding="3" cellspacing="0"
class="drgind_internal" style="height : 100%">
- <tr>
- <td class="drgind_marker">
- {marker}
- </td>
- <td class="drgind_text">
- <div class="drgind_wordcut drgind_text_content">
- {label}
- </div>
- </td>
- </tr>
- </table>
- <div class="drgind_shadow" />
-</f:root>