Author: abelevich
Date: 2010-12-30 10:44:17 -0500 (Thu, 30 Dec 2010)
New Revision: 20848
Added:
trunk/examples/dnd-demo/src/main/webapp/index.jsp
Modified:
trunk/examples/dnd-demo/src/main/java/org/demo/DataBean.java
trunk/examples/dnd-demo/src/main/webapp/examples/dnd.xhtml
trunk/ui/dnd/ui/src/main/resources/META-INF/resources/org.richfaces/dnd-droppable.js
Log:
RF-10056: 'acceptedTypes' attribute checking on null is added
Modified: trunk/examples/dnd-demo/src/main/java/org/demo/DataBean.java
===================================================================
--- trunk/examples/dnd-demo/src/main/java/org/demo/DataBean.java 2010-12-30 14:23:16 UTC
(rev 20847)
+++ trunk/examples/dnd-demo/src/main/java/org/demo/DataBean.java 2010-12-30 15:44:17 UTC
(rev 20848)
@@ -13,13 +13,10 @@
public class DataBean {
private List<String> dropValues = new ArrayList<String>();
-
private String dragValue1 = "dragValue 1";
-
- private String dragValue2 = "dragValue 3";
-
+ private String dragValue2 = "dragValue 2";
private String dragValue3 = "dragValue 3";
-
+ private String acceptedTypes = "drg1, drg2";
public List<String> getDropValues(){
return dropValues;
@@ -52,12 +49,29 @@
public void setDropValues(List<String> dropValues){
this.dropValues = dropValues;
}
-
+
+ public String getAcceptedTypes() {
+ return acceptedTypes;
+ }
+
+ public void setAcceptedTypes(String acceptedTypes) {
+ this.acceptedTypes = acceptedTypes;
+ }
+
public void processEvent(DropEvent event) {
String value = (String)event.getDragValue();
dropValues.add(value);
System.out.println("DataBean.processEvent()");
}
-
-
+
+ public void makeAcceptedTypesNullable(){
+ this.setAcceptedTypes(null);
+ this.setDropValues(new ArrayList<String>());
+ }
+
+ public void resetAcceptedTypes(){
+ this.setAcceptedTypes("drg1, drg2");
+ this.setDropValues(new ArrayList<String>());
+ }
+
}
Modified: trunk/examples/dnd-demo/src/main/webapp/examples/dnd.xhtml
===================================================================
--- trunk/examples/dnd-demo/src/main/webapp/examples/dnd.xhtml 2010-12-30 14:23:16 UTC
(rev 20847)
+++ trunk/examples/dnd-demo/src/main/webapp/examples/dnd.xhtml 2010-12-30 15:44:17 UTC
(rev 20848)
@@ -1,85 +1,102 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
-
xmlns:ui="http://java.sun.com/jsf/facelets"
-
xmlns:f="http://java.sun.com/jsf/core"
-
xmlns:h="http://java.sun.com/jsf/html"
-
xmlns:dnd="http://richfaces.org/dnd"
-
xmlns:a4j="http://richfaces.org/a4j">
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:dnd="http://richfaces.org/dnd"
+
xmlns:a4j="http://richfaces.org/a4j">
<h:head>
- <title>Drag-n-Drop sample</title>
- <style type="text/css">
-.droppable {
- border: 1px solid blue;
- margin: 4px;
- height: 200px;
- width: 200px;
- background-color: yellow;
- overflow: auto;
-}
+ <title>Drag-n-Drop sample</title>
+ <style type="text/css">
+ .droppable {
+ border: 1px solid blue;
+ margin: 4px;
+ height: 200px;
+ width: 200px;
+ background-color: yellow;
+ overflow: auto;
+ }
-.draggable {
- border: 1px solid #000000;
- background-color: grey;
- opacity: 0.3;
- margin: 2px;
- height: 50px;
- width: 100px;
-}
+ .draggable {
+ border: 1px solid #000000;
+ background-color: gray;
+ opacity: 0.3;
+ margin: 2px;
+ height: 50px;
+ width: 100px;
+ }
-.rf-ind {
- height: 20px;
- width: 20px;
- border: 1px dotted red;
- background-color: blue
-}
+ .rf-ind {
+ height: 20px;
+ width: 20px;
+ border: 1px dotted red;
+ background-color: blue
+ }
-.rf-ind-acpt {
- height: 20px;
- width: 20px;
- border: 1px dotted red;
- background-color: green;
-}
+ .rf-ind-acpt {
+ height: 20px;
+ width: 20px;
+ border: 1px dotted red;
+ background-color: green;
+ }
-.rf-ind-rejt {
- height: 20px;
- width: 20px;
- border: 1px dotted green;
- background-color: red;
-}
-</style>
+ .rf-ind-rejt {
+ height: 20px;
+ width: 20px;
+ border: 1px dotted green;
+ background-color: red;
+ }
+ </style>
</h:head>
<h:body>
- <h:form>
+ <h:form>
+ <dnd:dragIndicator id="ind"/>
+ <table>
+ <tr>
+ <td>
+ <a4j:outputPanel id="drg1" layout="block"
styleClass="draggable">
+ <h:outputText value="#{dataBean.dragValue1}"/>
+ <dnd:dragSource type="drg1"
dragValue="#{dataBean.dragValue1}"/>
+ </a4j:outputPanel>
+ </td>
+ <td>
+ <a4j:outputPanel id="drg2" layout="block"
styleClass="draggable">
+ <h:outputText value="#{dataBean.dragValue2}"/>
+ <dnd:dragSource type="drg2"
dragIndicator="ind" dragValue="#{dataBean.dragValue2}"/>
+ </a4j:outputPanel>
+ </td>
+ <td>
+ <a4j:outputPanel id="drg3" layout="block"
styleClass="draggable">
+ <h:outputText value="#{dataBean.dragValue3}"/>
+ <dnd:dragSource type="drg3"
dragIndicator="ind" dragValue="#{dataBean.dragValue3}"/>
+ </a4j:outputPanel>
+ </td>
+ <td>
+ <ul>
+ <li>
+ <a4j:commandLink value="Set acceptedTypes to [drg1,
drg2]"
+
action="#{dataBean.resetAcceptedTypes}"
+ render="drp"/>
+ </li>
+ <li>
+ <a4j:commandLink value="Make acceptedTypes nullable.
Every type will be accepted."
+
action="#{dataBean.makeAcceptedTypesNullable}"
+ render="drp"/>
+ </li>
+ </ul>
+ </td>
+ </tr>
+ </table>
- <dnd:dragIndicator id="ind"/>
-
- <table>
- <tr>
- <td><a4j:outputPanel id="drg1" layout="block"
styleClass="draggable">
- <h:outputText value="#{dataBean.dragValue1}"/>
- <dnd:dragSource type="drg1"
dragValue="#{dataBean.dragValue1}"/>
- </a4j:outputPanel></td>
- <td><a4j:outputPanel id="drg2" layout="block"
styleClass="draggable">
- <h:outputText value="#{dataBean.dragValue2}"/>
- <dnd:dragSource type="drg2" dragIndicator="ind"
dragValue="#{dataBean.dragValue2}"/>
- </a4j:outputPanel></td>
- <td><a4j:outputPanel id="drg3" layout="block"
styleClass="draggable">
- <h:outputText value="#{dataBean.dragValue3}"/>
- <dnd:dragSource type="drg3" dragIndicator="ind"
dragValue="#{dataBean.dragValue3}"/>
- </a4j:outputPanel></td>
- </tr>
- </table>
-
- <a4j:outputPanel id="drp" layout="block"
styleClass="droppable">
- <dnd:dropTarget acceptedTypes="drg1, drg2"
dropListener="#{dataBean.processEvent}"
render="grid"></dnd:dropTarget>
- <h:dataTable id="grid" var="dropValue"
value="#{dataBean.dropValues}">
- <h:column>
- <h:outputText value="#{dropValue}"/>
- </h:column>
- </h:dataTable>
- </a4j:outputPanel>
-
- </h:form>
+ <a4j:outputPanel id="drp" layout="block"
styleClass="droppable">
+ <dnd:dropTarget acceptedTypes="#{dataBean.acceptedTypes}"
dropListener="#{dataBean.processEvent}"
+ render="grid"/>
+ <h:dataTable id="grid" var="dropValue"
value="#{dataBean.dropValues}">
+ <h:column>
+ <h:outputText value="#{dropValue}"/>
+ </h:column>
+ </h:dataTable>
+ </a4j:outputPanel>
+ </h:form>
</h:body>
</html>
\ No newline at end of file
Added: trunk/examples/dnd-demo/src/main/webapp/index.jsp
===================================================================
--- trunk/examples/dnd-demo/src/main/webapp/index.jsp (rev 0)
+++ trunk/examples/dnd-demo/src/main/webapp/index.jsp 2010-12-30 15:44:17 UTC (rev 20848)
@@ -0,0 +1 @@
+<jsp:forward page="examples/dnd.jsf" />
\ No newline at end of file
Modified:
trunk/ui/dnd/ui/src/main/resources/META-INF/resources/org.richfaces/dnd-droppable.js
===================================================================
---
trunk/ui/dnd/ui/src/main/resources/META-INF/resources/org.richfaces/dnd-droppable.js 2010-12-30
14:23:16 UTC (rev 20847)
+++
trunk/ui/dnd/ui/src/main/resources/META-INF/resources/org.richfaces/dnd-droppable.js 2010-12-30
15:44:17 UTC (rev 20848)
@@ -60,6 +60,10 @@
},
accept: function(draggable) {
+ // since acceptedTypes is optional it could be null.
+ // In this case all types are accepted
+ if(!this.options.acceptedTypes) return true;
+
var accept;
var acceptType = draggable.data("type");
if(acceptType) {