Update of /var/cvs/src/org/mmbase/datatypes/processors
In directory james.mmbase.org:/tmp/cvs-serv16034

Modified Files:
        FunctionValueIfEmptyCommitProcessor.java 
Added Files:
        FunctionValueIfEmptyGetter.java 
Log Message:
MMB-1612


See also: http://cvs.mmbase.org/viewcvs/src/org/mmbase/datatypes/processors
See also: http://www.mmbase.org/jira/browse/MMB-1612




Index: FunctionValueIfEmptyCommitProcessor.java
===================================================================
RCS file: 
/var/cvs/src/org/mmbase/datatypes/processors/FunctionValueIfEmptyCommitProcessor.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- FunctionValueIfEmptyCommitProcessor.java    3 Feb 2008 17:33:57 -0000       
1.3
+++ FunctionValueIfEmptyCommitProcessor.java    2 Apr 2008 12:37:17 -0000       
1.4
@@ -16,8 +16,11 @@
  * If this commit-processor is configured on a field, then on commit of the 
node, the value of a
  * certain function (on the same node), is set into the field, if the field is 
empty.
  *
+ * It also implements simply copying the value of another field in such cases 
(using the
+ * 'fieldName') parameter.
+ *
  * @author Michiel Meeuwissen
- * @version $Id: FunctionValueIfEmptyCommitProcessor.java,v 1.3 2008/02/03 
17:33:57 nklasens Exp $
+ * @version $Id: FunctionValueIfEmptyCommitProcessor.java,v 1.4 2008/04/02 
12:37:17 michiel Exp $
  * @since MMBase-1.8.5
  */
 
@@ -27,13 +30,21 @@
 
     private static final long serialVersionUID = 1L;
     private String functionName;
+    private String fieldName;
     public void setFunctionName(String fn) {
         functionName = fn;
     }
+    public void setFieldName(String fn) {
+        fieldName = fn;
+    }
 
     public void commit(Node node, Field field) {
         if (node.getValue(field.getName()) == null || 
"".equals(node.getStringValue(field.getName()))) {
-            node.setValue(field.getName(), node.getFunctionValue(functionName, 
null));
+            if (fieldName != null) {
+                node.setValueWithoutProcess(field.getName(), 
node.getValue(fieldName));
+            } else {
+                node.setValue(field.getName(), 
node.getFunctionValue(functionName, null).get());
+            }
         }
     }
 
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to