Author: abelevich
Date: 2011-02-02 13:21:44 -0500 (Wed, 02 Feb 2011)
New Revision: 21399
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/java/org/richfaces/component/AbstractDropTarget.java
Log:
RF-10334 Drop Target - add @immediate, @bypassUpdates and @execute attributes
Modified: trunk/examples/dnd-demo/src/main/java/org/demo/DataBean.java
===================================================================
--- trunk/examples/dnd-demo/src/main/java/org/demo/DataBean.java 2011-02-02 18:14:00 UTC
(rev 21398)
+++ trunk/examples/dnd-demo/src/main/java/org/demo/DataBean.java 2011-02-02 18:21:44 UTC
(rev 21399)
@@ -17,7 +17,56 @@
private String dragValue2 = "dragValue 2";
private String dragValue3 = "dragValue 3";
private String acceptedTypes = "drg1, drg2";
+ private String phaseId = "none";
+ private boolean immediate = false;
+ private boolean bypassUpdates = false;
+ private Object execute;
+ private String executeTest = "none";
+
+ public String getExecuteTest() {
+ return executeTest;
+ }
+
+ public void setExecuteTest(String executeTest) {
+ this.executeTest = executeTest;
+ }
+ public Object getExecute() {
+ return execute;
+ }
+
+ public void setExecute(Object execute) {
+ this.execute = execute;
+ }
+
+
+
+ public boolean isImmediate() {
+ return immediate;
+ }
+
+ public void setImmediate(boolean immediate) {
+ this.immediate = immediate;
+ }
+
+ public boolean isBypassUpdates() {
+ return bypassUpdates;
+ }
+
+ public void setBypassUpdates(boolean bypassUpdates) {
+ this.bypassUpdates = bypassUpdates;
+ }
+
+ public String getPhaseId() {
+ return phaseId;
+ }
+
+ public void setPhaseId(String phaseId) {
+ this.phaseId = phaseId;
+ }
+
+
+
public List<String> getDropValues(){
return dropValues;
}
@@ -58,10 +107,8 @@
this.acceptedTypes = acceptedTypes;
}
- public void processEvent(DropEvent event) {
- String value = (String)event.getDragValue();
- dropValues.add(value);
- System.out.println("DataBean.processEvent()");
+ public void addDropValues(String value){
+ dropValues.add(value);
}
public void makeAcceptedTypesNullable(){
Modified: trunk/examples/dnd-demo/src/main/webapp/examples/dnd.xhtml
===================================================================
--- trunk/examples/dnd-demo/src/main/webapp/examples/dnd.xhtml 2011-02-02 18:14:00 UTC
(rev 21398)
+++ trunk/examples/dnd-demo/src/main/webapp/examples/dnd.xhtml 2011-02-02 18:21:44 UTC
(rev 21399)
@@ -83,20 +83,37 @@
action="#{dataBean.makeAcceptedTypesNullable}"
render="drp"/>
</li>
+ <li>
+ <h:outputText value="Immediate:"/>
+ <h:selectBooleanCheckbox
value="#{dataBean.immediate}">
+ <a4j:ajax render="drp @this"/>
+ </h:selectBooleanCheckbox>
+ </li>
+ <li>
+ <h:outputText value="bypassUpdates:"/>
+ <h:selectBooleanCheckbox
value="#{dataBean.bypassUpdates}">
+ <a4j:ajax render="drp @this"/>
+ </h:selectBooleanCheckbox>
+ </li>
</ul>
</td>
</tr>
</table>
<a4j:outputPanel id="drp" layout="block"
styleClass="droppable">
- <dnd:dropTarget acceptedTypes="#{dataBean.acceptedTypes}"
dropListener="#{dataBean.processEvent}"
- render="grid"/>
+ <dnd:dropTarget acceptedTypes="#{dataBean.acceptedTypes}"
dropListener="#{dropListenerBean.processDrop}"
+ render="grid executeOut"
execute="executeIn" immediate="#{dataBean.immediate}"
bypassUpdates="#{dataBean.bypassUpdates}"/>
<h:dataTable id="grid" var="dropValue"
value="#{dataBean.dropValues}">
<h:column>
- <h:outputText value="#{dropValue}"/>
+ <h:outputText value="#{dropValue}"/> :
<h:outputText value="#{dataBean.phaseId}" />;
</h:column>
</h:dataTable>
</a4j:outputPanel>
+
+ <a4j:outputPanel id="execute" layout="block">
+ <h:inputText id="executeIn"
value="#{dataBean.executeTest}"/> <br/>
+ <h:outputText id="executeOut"
value="#{dataBean.executeTest}"/> <br/>
+ </a4j:outputPanel>
</h:form>
</h:body>
</html>
\ No newline at end of file
Modified: trunk/ui/dnd/ui/src/main/java/org/richfaces/component/AbstractDropTarget.java
===================================================================
---
trunk/ui/dnd/ui/src/main/java/org/richfaces/component/AbstractDropTarget.java 2011-02-02
18:14:00 UTC (rev 21398)
+++
trunk/ui/dnd/ui/src/main/java/org/richfaces/component/AbstractDropTarget.java 2011-02-02
18:21:44 UTC (rev 21399)
@@ -47,29 +47,50 @@
tag = @Tag(name="dropTarget"
,handler="org.richfaces.view.facelets.DropHandler", type = TagType.Facelets)
)
public abstract class AbstractDropTarget extends UIComponentBase {
-
+
public static final String COMPONENT_TYPE = "org.richfaces.DropTarget";
- public static final String COMPONENT_FAMILY = "org.richfaces.DropTarget";
-
-
+ public static final String COMPONENT_FAMILY = "org.richfaces.DropTarget";
+
+
@Attribute
public abstract Object getDropValue();
-
+
+ @Attribute
+ public abstract boolean isImmediate();
+
+ @Attribute
+ public abstract boolean isBypassUpdates();
+
+ @Attribute
+ public abstract Object getExecute();
+
public abstract Object getAcceptedTypes();
-
+
public void addDropListener(DropListener listener) {
addFacesListener(listener);
}
+
+ public DropListener[] getDropListeners() {
+ return (DropListener[]) getFacesListeners(DropListener.class);
+ }
public void removeDropListener(DropListener listener) {
removeFacesListener(listener);
}
-
+
@Override
public void queueEvent(FacesEvent event) {
- if(event instanceof DropEvent) {
- event.setPhaseId(PhaseId.INVOKE_APPLICATION);
+ if (event instanceof DropEvent) {
+
+ if (isImmediate()) {
+ event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
+ } else if (isBypassUpdates()) {
+ event.setPhaseId(PhaseId.PROCESS_VALIDATIONS);
+ } else {
+ event.setPhaseId(PhaseId.INVOKE_APPLICATION);
+ }
+
}
super.queueEvent(event);
}
Show replies by date