Author: pgolawski
Date: 2008-09-15 05:45:26 -0400 (Mon, 15 Sep 2008)
New Revision: 10439
Modified:
trunk/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/ExtDraggableRendererContributor.java
trunk/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/ExtDropzoneRendererContributor.java
Log:
organize imports +
send request only if drag column in not equals to drop column
Modified:
trunk/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/ExtDraggableRendererContributor.java
===================================================================
---
trunk/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/ExtDraggableRendererContributor.java 2008-09-12
15:30:13 UTC (rev 10438)
+++
trunk/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/ExtDraggableRendererContributor.java 2008-09-15
09:45:26 UTC (rev 10439)
@@ -10,6 +10,7 @@
import javax.faces.context.FacesContext;
import org.richfaces.renderkit.CompositeRenderer;
+import org.richfaces.renderkit.DraggableRendererContributor;
import org.richfaces.renderkit.RendererContributor;
import org.richfaces.renderkit.ScriptOptions;
@@ -39,7 +40,7 @@
public static synchronized ExtDraggableRendererContributor getInstance() {
if (instance == null) {
instance = new ExtDraggableRendererContributor();
- wrappedContributor =
org.richfaces.renderkit.DraggableRendererContributor.getInstance();
+ wrappedContributor = DraggableRendererContributor.getInstance();
}
return instance;
}
@@ -96,7 +97,7 @@
Map<String, Object> parameters = new HashMap<String, Object>();
parameters
.put(
-
org.richfaces.renderkit.DraggableRendererContributor.DRAG_SOURCE_ID,
+ DraggableRendererContributor.DRAG_SOURCE_ID,
dragSourceScriptId);
parameters.put(dragSourceScriptId, dragSourceScriptId);
options.addOption("parameters", parameters);
Modified:
trunk/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/ExtDropzoneRendererContributor.java
===================================================================
---
trunk/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/ExtDropzoneRendererContributor.java 2008-09-12
15:30:13 UTC (rev 10438)
+++
trunk/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/ExtDropzoneRendererContributor.java 2008-09-15
09:45:26 UTC (rev 10439)
@@ -14,6 +14,8 @@
import org.ajax4jsf.javascript.ScriptUtils;
import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.richfaces.renderkit.CompositeRenderer;
+import org.richfaces.renderkit.DraggableRendererContributor;
+import org.richfaces.renderkit.DropzoneRendererContributor;
import org.richfaces.renderkit.RendererContributor;
import org.richfaces.renderkit.ScriptOptions;
@@ -41,7 +43,7 @@
public static synchronized ExtDropzoneRendererContributor getInstance() {
if (instance == null) {
instance = new ExtDropzoneRendererContributor();
- wrappedContributor =
org.richfaces.renderkit.DropzoneRendererContributor.getInstance();
+ wrappedContributor = DropzoneRendererContributor.getInstance();
}
return instance;
@@ -88,22 +90,31 @@
}
}
- if (preSendAjaxRequestFunction != null){
- definition.addToBody(preSendAjaxRequestFunction.toScript()).addToBody(";");
- }
+ definition.addToBody("var dragParams = drag.getParameters();");
+
+ String dragSourceScriptId = column.getClientId(context) + ":"+
TableDragDropRenderer.DRAG_SOURCE_SCRIPT_ID;
+ definition.addToBody(
+ "var source = dragParams['"+ DraggableRendererContributor.DRAG_SOURCE_ID
+"'];" +
+ "if (source != \"" + dragSourceScriptId + "\"){"//send
request only if drag column in not equals to drop column
+ );
definition.addToBody("var options =
").addToBody(ScriptUtils.toScript(requestOpts)).addToBody(";");
- definition.addToBody("options.parameters['" +
org.richfaces.renderkit.DropzoneRendererContributor.DROP_TARGET_ID + "'] =
'" + dropTargetScriptId + "';");
-
+ definition.addToBody("options.parameters['" +
DropzoneRendererContributor.DROP_TARGET_ID + "'] = '" +
dropTargetScriptId + "';");
if (onAjaxCompleteFunction != null)
definition.addToBody("options['" +
AjaxRendererUtils.ONCOMPLETE_ATTR_NAME + "'] = " +
onAjaxCompleteFunction.toScript() + ";");
//TODO remove as legacy
- definition.addToBody("Object.extend(options.parameters,drag.getParameters());");
+ definition.addToBody("Object.extend(options.parameters, dragParams);");
+ if (preSendAjaxRequestFunction != null){
+ definition.addToBody(preSendAjaxRequestFunction.toScript()).addToBody(";");
+ }
definition.addToBody("var dzOptions = this.getDropzoneOptions(); if
(dzOptions.ondrop) { if (!dzOptions.ondrop.call(this, event)) return; };");
JSFunction dropFunction = AjaxRendererUtils.buildAjaxFunction(column, context);
dropFunction.addParameter(new JSReference("options"));
definition.addToBody(dropFunction.toScript()).addToBody(";");
+
+ definition.addToBody("};");
+
definition.appendScript(result);
result.append(";");