cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r124968 - in cocoon/branches/BRANCH_2_1_X/src: blocks/forms/java/org/apache/cocoon/forms/binding documentation/xdocs/userdocs/forms
Date Wed, 12 Jan 2005 11:17:44 GMT
Author: cziegeler
Date: Wed Jan 12 03:17:39 2005
New Revision: 124968

URL: http://svn.apache.org/viewcvs?view=rev&rev=124968
Log:
[PATCH] Allow to use fb:insert-bean with add methods without a parameter submitted by  Jens
Maukisch <jmaukisch@s-und-n.de>  
Modified:
   cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/InsertBeanJXPathBinding.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/InsertBeanJXPathBindingBuilder.java
   cocoon/branches/BRANCH_2_1_X/src/documentation/xdocs/userdocs/forms/binding.xml

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/InsertBeanJXPathBinding.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/InsertBeanJXPathBinding.java?view=diff&rev=124968&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/InsertBeanJXPathBinding.java&r1=124967&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/InsertBeanJXPathBinding.java&r2=124968
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/InsertBeanJXPathBinding.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/InsertBeanJXPathBinding.java
Wed Jan 12 03:17:39 2005
@@ -23,8 +23,8 @@
 
 /**
  * InsertBeanJXPathBinding provides an implementation of a {@link Binding}
- * that inserts a new instance of the specified bean (classname) into the target
- * back-end model upon save.
+ * that inserts a new instance of the specified bean (classname) or a new instance
+ * created by the model itself into the target back-end model upon save.
  * <p>
  * NOTES: <ol>
  * <li>This Binding does not perform any actions when loading.</li>
@@ -58,7 +58,8 @@
      * Registers a JXPath Factory on the JXPath Context.
      * <p>
      * The factory will insert a new instance of the specified bean (classname)
-     * inside this object into the target objectmodel.
+     * inside this object into the target objectmodel or it will just call the
+     * add method if classname is null.
      */
     public void doSave(Widget frmModel, JXPathContext jxpc) throws BindingException {
         try {
@@ -67,8 +68,13 @@
             Class[] argTypes = new Class[1];
 
             // instantiate the new object
-            argTypes[0] = Class.forName(this.className);
-            args[0] = argTypes[0].newInstance();
+            if(this.className != null) {
+	            argTypes[0] = Class.forName(this.className);
+	            args[0] = argTypes[0].newInstance();
+            } else {
+            	argTypes = null;
+            	args = null;
+            }
 
             // lookup the named method on the parent
             Method addMethod =

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/InsertBeanJXPathBindingBuilder.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/InsertBeanJXPathBindingBuilder.java?view=diff&rev=124968&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/InsertBeanJXPathBindingBuilder.java&r1=124967&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/InsertBeanJXPathBindingBuilder.java&r2=124968
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/InsertBeanJXPathBindingBuilder.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/InsertBeanJXPathBindingBuilder.java
Wed Jan 12 03:17:39 2005
@@ -27,7 +27,11 @@
  * <pre><code>
  * &lt;fb:insert-bean classname="..child-bean-class.." addmethod="..method-to-add.."/&gt;
  * </code></pre>
- *
+ * or if the add method creates the new instance itself:
+ * <pre><code>
+ * &lt;fb:insert-bean addmethod="..method-to-add.."/&gt;
+ * </code></pre>
+ *  
  * @version CVS $Id$
  */
 public class InsertBeanJXPathBindingBuilder extends JXPathBindingBuilderBase {
@@ -42,7 +46,7 @@
             CommonAttributes commonAtts = JXPathBindingBuilderBase.getCommonAttributes(bindingElm);
 
             String className =
-                DomHelper.getAttribute(bindingElm, "classname");
+                DomHelper.getAttribute(bindingElm, "classname", null);
             String addMethod =
                 DomHelper.getAttribute(bindingElm, "addmethod");
 

Modified: cocoon/branches/BRANCH_2_1_X/src/documentation/xdocs/userdocs/forms/binding.xml
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/documentation/xdocs/userdocs/forms/binding.xml?view=diff&rev=124968&p1=cocoon/branches/BRANCH_2_1_X/src/documentation/xdocs/userdocs/forms/binding.xml&r1=124967&p2=cocoon/branches/BRANCH_2_1_X/src/documentation/xdocs/userdocs/forms/binding.xml&r2=124968
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/documentation/xdocs/userdocs/forms/binding.xml	(original)
+++ cocoon/branches/BRANCH_2_1_X/src/documentation/xdocs/userdocs/forms/binding.xml	Wed Jan
12 03:17:39 2005
@@ -157,7 +157,7 @@
         <tr>
           <td>fb:insert-bean</td>
           <td>inserts an object in a list-type bean property</td>
-          <td>classname, addmethod</td>
+          <td>addmethod, classname (optional)</td>
           <td>none</td>
         </tr>
         <tr>
@@ -495,16 +495,18 @@
       <s2 title="fb:insert-bean">
         <p>Attributes:</p>
         <ul>
-          <li>classname</li>
           <li>addmethod</li>
+          <li>classname (optional)</li>
           <li>direction (optional)</li>
         </ul>
 
         <p>This binding element can only be used when the target object is a Javabean.</p>
 
-        <p>It instantiates a new object of the type specified in the classname
-        attribute and calls the method specified in the addmethod attribute on the
-        current context object with the newly instantiated object as argument.</p>
+        <p>If classname is specified it instantiates a new object of the type specified

+        in the classname attribute and calls the method specified in the addmethod 
+        attribute on the current context object with the newly instantiated object as argument.
+        If classname is not specified it will just call the addmethod (e.g. if the addmethod
creates
+        the new instance itself).</p>
 
         <p><strong>NOTE:</strong> This binding is never active in the 'load'
operation,
         so there is no need to specify the <code>direction="save"</code> to protect
you model

Mime
View raw message