Author: nbelaevski
Date: 2011-02-03 14:50:48 -0500 (Thu, 03 Feb 2011)
New Revision: 21432
Modified:
trunk/ui/dnd/ui/src/main/java/org/richfaces/renderkit/DropTargetRenderer.java
Log:
https://issues.jboss.org/browse/RF-10428
Modified: trunk/ui/dnd/ui/src/main/java/org/richfaces/renderkit/DropTargetRenderer.java
===================================================================
---
trunk/ui/dnd/ui/src/main/java/org/richfaces/renderkit/DropTargetRenderer.java 2011-02-03
19:44:13 UTC (rev 21431)
+++
trunk/ui/dnd/ui/src/main/java/org/richfaces/renderkit/DropTargetRenderer.java 2011-02-03
19:50:48 UTC (rev 21432)
@@ -40,7 +40,9 @@
import org.richfaces.renderkit.util.AjaxRendererUtils;
import org.richfaces.renderkit.util.CoreAjaxRendererUtils;
+import com.google.common.base.Strings;
+
/**
* @author abelevich
*
@@ -51,19 +53,29 @@
@Override
protected void doDecode(FacesContext facesContext, UIComponent component) {
- if(component instanceof AbstractDropTarget) {
- Map<String, String> requestParamMap =
facesContext.getExternalContext().getRequestParameterMap();
- String dragSourceId = (String) requestParamMap.get("dragSource");
-
- if(dragSourceId !=null && !"".equals(dragSourceId)) {
- DragSourceContextCallBack dragSourceContextCallBack = new
DragSourceContextCallBack();
- facesContext.getViewRoot().invokeOnComponent(facesContext, dragSourceId,
dragSourceContextCallBack);
-
- AbstractDropTarget dropTarget = (AbstractDropTarget)component;
- new DropEvent(dropTarget, dropTarget.getDropValue(),
- dragSourceContextCallBack.getDragSource(),
dragSourceContextCallBack.getDragValue()).queue();
- }
+ Map<String, String> requestParamMap =
facesContext.getExternalContext().getRequestParameterMap();
+
+ if (requestParamMap.get(component.getClientId(facesContext)) == null) {
+ return;
}
+
+ String dragSourceId = (String) requestParamMap.get("dragSource");
+ if (Strings.isNullOrEmpty(dragSourceId)) {
+ return;
+ }
+
+
+ DragSourceContextCallBack dragSourceContextCallBack = new
DragSourceContextCallBack();
+ boolean invocationResult =
facesContext.getViewRoot().invokeOnComponent(facesContext, dragSourceId,
dragSourceContextCallBack);
+
+ if (!invocationResult) {
+ //TODO - log
+ return;
+ }
+
+ AbstractDropTarget dropTarget = (AbstractDropTarget) component;
+ new DropEvent(dropTarget, dropTarget.getDropValue(),
+ dragSourceContextCallBack.getDragSource(),
dragSourceContextCallBack.getDragValue()).queue();
}
private final class DragSourceContextCallBack implements ContextCallback {
@@ -103,6 +115,7 @@
AjaxFunction ajaxFunction = AjaxRendererUtils.buildAjaxFunction(facesContext,
component);
ajaxFunction.getOptions().setParameter("dragSource",
dragSourceId);
+ ajaxFunction.getOptions().setParameter(component.getClientId(facesContext),
component.getClientId(facesContext));
ajaxFunction.setSource(new JSReference("event",
"target"));
ajaxFunction.getOptions().setAjaxComponent(component.getClientId(facesContext));
function.addToBody(ajaxFunction);