Author: abelevich
Date: 2010-12-15 14:06:55 -0500 (Wed, 15 Dec 2010)
New Revision: 20593
Modified:
trunk/ui/dnd/api/src/main/java/org/richfaces/event/DropEvent.java
trunk/ui/dnd/ui/src/main/java/org/richfaces/renderkit/DropBehaviorRendererBase.java
Log:
fix possible issue with drag drop columns in the dataTable
Modified: trunk/ui/dnd/api/src/main/java/org/richfaces/event/DropEvent.java
===================================================================
--- trunk/ui/dnd/api/src/main/java/org/richfaces/event/DropEvent.java 2010-12-15 17:57:11
UTC (rev 20592)
+++ trunk/ui/dnd/api/src/main/java/org/richfaces/event/DropEvent.java 2010-12-15 19:06:55
UTC (rev 20593)
@@ -37,23 +37,65 @@
private static final long serialVersionUID = 3717071628237886288L;
- private ClientDragBehavior dragSource;
+ private ClientDragBehavior dragBehavior;
private UIComponent dragComponent;
+ private ClientDropBehavior dropBehavior;
+
+ private UIComponent dropComponent;
+
+ private Object dropValue;
+
+ private Object dragValue;
+
public DropEvent(UIComponent component, ClientDropBehavior behavior) {
super(component, behavior);
+ this.dropComponent = component;
+ this.dropBehavior = behavior;
}
- public ClientDragBehavior getDragSource() {
- return dragSource;
+
+ public void setDropBehavior(ClientDropBehavior dropBehavior) {
+ this.dropBehavior = dropBehavior;
}
+
+ public ClientDropBehavior getDropBehavior() {
+ return this.dropBehavior;
+ }
+
+ public void setDropComponent(UIComponent dropComponent) {
+ this.dropComponent = dropComponent;
+ }
+
+ public UIComponent getDropComponent() {
+ return this.dropComponent;
+ }
+ public Object getDropValue() {
+ return dropValue;
+ }
- public void setDragSource(ClientDragBehavior dragSource) {
- this.dragSource = dragSource;
+ public void setDropValue(Object dropValue) {
+ this.dropValue = dropValue;
}
+ public Object getDragValue() {
+ return dragValue;
+ }
+
+ public void setDragValue(Object dragValue) {
+ this.dragValue = dragValue;
+ }
+
+ public ClientDragBehavior getDragBehavior() {
+ return dragBehavior;
+ }
+
+ public void setDragBehavior(ClientDragBehavior dragBehavior) {
+ this.dragBehavior = dragBehavior;
+ }
+
public UIComponent getDragComponent() {
return dragComponent;
}
@@ -61,16 +103,7 @@
public void setDragComponent(UIComponent dragComponent) {
this.dragComponent = dragComponent;
}
-
- public ClientDropBehavior getDropSource() {
- return (ClientDropBehavior)getBehavior();
- }
- public UIComponent getDropComponent() {
- return getComponent();
- }
-
-
@Override
public boolean isAppropriateListener(FacesListener listener) {
return (listener instanceof DropListener);
@@ -80,5 +113,4 @@
public void processListener(FacesListener listener) {
((DropListener) listener).processDrop(this);
}
-
}
\ No newline at end of file
Modified:
trunk/ui/dnd/ui/src/main/java/org/richfaces/renderkit/DropBehaviorRendererBase.java
===================================================================
---
trunk/ui/dnd/ui/src/main/java/org/richfaces/renderkit/DropBehaviorRendererBase.java 2010-12-15
17:57:11 UTC (rev 20592)
+++
trunk/ui/dnd/ui/src/main/java/org/richfaces/renderkit/DropBehaviorRendererBase.java 2010-12-15
19:06:55 UTC (rev 20593)
@@ -76,7 +76,19 @@
Map<String, String> requestParamMap =
facesContext.getExternalContext().getRequestParameterMap();
String dragSource = (String) requestParamMap.get("dragSource");
- facesContext.getViewRoot().invokeOnComponent(facesContext, dragSource, new
DropBehaviorContextCallBack(component, (ClientDropBehavior)behavior));
+
+ DragBehaviorContextCallBack dragBehaviorContextCallBack = new
DragBehaviorContextCallBack();
+ facesContext.getViewRoot().invokeOnComponent(facesContext, dragSource,
dragBehaviorContextCallBack);
+
+ if(behavior instanceof ClientDropBehavior) {
+ ClientDropBehavior dropBehavior = (ClientDropBehavior)behavior;
+ DropEvent dropEvent = new DropEvent(component, dropBehavior);
+ dropEvent.setDropValue(dropBehavior.getDropValue());
+ dropEvent.setDragComponent(dragBehaviorContextCallBack.getDragComponent());
+ dropEvent.setDragBehavior(dragBehaviorContextCallBack.getDragBehavior());
+ dropEvent.setDragValue(dragBehaviorContextCallBack.getDragValue());
+ queueEvent(dropEvent);
+ }
}
@Override
@@ -91,67 +103,36 @@
ClientDropBehavior dropBehavior = (ClientDropBehavior)behavior;
options.put("acceptedTypes", dropBehavior.getAcceptedTypes());
}
-
return options;
}
- private final class DropBehaviorContextCallBack implements ContextCallback {
+ private final class DragBehaviorContextCallBack implements ContextCallback {
- private ClientDropBehavior dropBehavior;
+ private Object dragValue;
- private UIComponent dropSource;
+ private ClientDragBehavior dragBehavior;
- public DropBehaviorContextCallBack(UIComponent dropSource, ClientDropBehavior
dropBehavior) {
- this.dropSource = dropSource;
- this.dropBehavior = dropBehavior;
- }
+ private UIComponent dragComponent;
public void invokeContextCallback(FacesContext context, UIComponent target) {
ClientDragBehavior dragBehavior = getDragBehavior(target,
"mouseover");
- if(dragBehavior != null) {
- DropEvent dropEvent = new DropEvent(dropSource, dropBehavior);
- dropEvent.setDragSource(dragBehavior);
- dropEvent.setDragComponent(target);
- queueDropEvent(dropEvent);
- } else {
- //TODO: log
- }
+ this.dragValue = dragBehavior.getDragValue();
+ this.dragBehavior = dragBehavior;
+ this.dragComponent = target;
}
- private void queueDropEvent(DropEvent event) {
- PhaseId phaseId = PhaseId.INVOKE_APPLICATION;
-
- if (isImmediate()) {
- phaseId = PhaseId.APPLY_REQUEST_VALUES;
- } else if (isBypassUpdates()) {
- phaseId = PhaseId.PROCESS_VALIDATIONS;
- }
+ public Object getDragValue() {
+ return dragValue;
+ }
- event.setPhaseId(phaseId);
- this.dropSource.queueEvent(event);
+ public ClientDragBehavior getDragBehavior() {
+ return dragBehavior;
}
-
- private boolean isImmediate(){
- boolean immediate = this.dropBehavior.isImmediate();
- if(!immediate) {
- if (dropSource instanceof EditableValueHolder) {
- immediate = ((EditableValueHolder) dropSource).isImmediate();
- } else if (dropSource instanceof ActionSource) {
- immediate = ((ActionSource) dropSource).isImmediate();
- }
- }
-
- return immediate;
+
+ public UIComponent getDragComponent() {
+ return dragComponent;
}
- private boolean isBypassUpdates(){
- boolean bypassUpdates = this.dropBehavior.isBypassUpdates();
- if (!bypassUpdates) {
- bypassUpdates = getUtils().isBooleanAttribute(this.dropSource,
"bypassUpdates");
- }
- return bypassUpdates;
- }
-
private ClientDragBehavior getDragBehavior(UIComponent parent, String event) {
if(parent instanceof ClientBehaviorHolder) {
Map<String, List<ClientBehavior>> behaviorsMap =
((ClientBehaviorHolder)parent).getClientBehaviors();
@@ -173,5 +154,43 @@
}
}
+
+ protected void queueEvent(DropEvent dropEvent){
+ UIComponent component = dropEvent.getComponent();
+ ClientDropBehavior dropBehavior = dropEvent.getDropBehavior();
+
+ if(component != null && dropBehavior != null) {
+ PhaseId phaseId = PhaseId.INVOKE_APPLICATION;
+ if (isImmediate(component, dropBehavior)) {
+ phaseId = PhaseId.APPLY_REQUEST_VALUES;
+ } else if (isBypassUpdates(component, dropBehavior)) {
+ phaseId = PhaseId.PROCESS_VALIDATIONS;
+ }
+
+ dropEvent.setPhaseId(phaseId);
+ component.queueEvent(dropEvent);
+ }
+ }
+
+ private boolean isImmediate(UIComponent component, ClientDropBehavior dropBehavior){
+ boolean immediate = dropBehavior.isImmediate();
+ if(!immediate) {
+ if (component instanceof EditableValueHolder) {
+ immediate = ((EditableValueHolder) component).isImmediate();
+ } else if (component instanceof ActionSource) {
+ immediate = ((ActionSource) component).isImmediate();
+ }
+ }
+ return immediate;
+ }
+
+ private boolean isBypassUpdates(UIComponent component, ClientDropBehavior
dropBehavior){
+ boolean bypassUpdates = dropBehavior.isBypassUpdates();
+ if (!bypassUpdates) {
+ bypassUpdates = getUtils().isBooleanAttribute(component,
"bypassUpdates");
+ }
+ return bypassUpdates;
+ }
+
}