cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r375253 - in /cocoon: branches/BRANCH_2_1_X/ trunk/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/binding/ trunk/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/samples/bindings/
Date Mon, 06 Feb 2006 11:36:11 GMT
Author: jbq
Date: Mon Feb  6 03:36:07 2006
New Revision: 375253

URL: http://svn.apache.org/viewcvs?rev=375253&view=rev
Log:
Fix COCOON-1238: Improvements for CustomJXPathBinding

Modified:
    cocoon/branches/BRANCH_2_1_X/status.xml
    cocoon/trunk/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/binding/AbstractCustomBinding.java
    cocoon/trunk/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/binding/CustomJXPathBinding.java
    cocoon/trunk/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/binding/CustomJXPathBindingBuilder.java
    cocoon/trunk/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/samples/bindings/CustomValueWrapBinding.java

Modified: cocoon/branches/BRANCH_2_1_X/status.xml
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/status.xml?rev=375253&r1=375252&r2=375253&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/status.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/status.xml Mon Feb  6 03:36:07 2006
@@ -180,6 +180,13 @@
   <release version="@version@" date="@date@">
 -->
   <release version="2.1.9" date="TBD">
+    <action dev="JBQ" type="fix" fixes-bug="COCOON-1238" due-to="Bart Molenkamp" due-to-email="b.molenkamp@bizzdesign.nl">
+      CForms: Incompatible change for &lt;fb:custom&gt;: the base context is now
passed instead of the relative context.
+      <strong>Please change corresponding classes and use getXpath() to create the
relative context yourself</strong>.
+    </action>
+    <action dev="JBQ" type="add" fixes-bug="COCOON-1238" due-to="Bart Molenkamp" due-to-email="b.molenkamp@bizzdesign.nl">
+      CForms: Classes used in &lt;fb:custom&gt; can now implement Serviceable to
get a ServiceManager
+    </action>
     <action dev="JBQ" type="fix" fixes-bug="COCOON-1558" due-to="Jochen Kuhnle" due-to-email="werbung@kuhnle.net">
       CForms: fix &lt;ft:validation-error&gt; handling when used with FormsTemplateTransformer
     </action>

Modified: cocoon/trunk/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/binding/AbstractCustomBinding.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/binding/AbstractCustomBinding.java?rev=375253&r1=375252&r2=375253&view=diff
==============================================================================
--- cocoon/trunk/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/binding/AbstractCustomBinding.java
(original)
+++ cocoon/trunk/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/binding/AbstractCustomBinding.java
Mon Feb  6 03:36:07 2006
@@ -28,6 +28,16 @@
     private Binding parent;
     private String id;
 
+    private String xpath;
+
+    public void setXpath(String path) {
+        this.xpath = path;
+    }
+
+    public String getXpath() {
+        return xpath;
+    }
+
     /**
      * Sets parent binding.
      */

Modified: cocoon/trunk/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/binding/CustomJXPathBinding.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/binding/CustomJXPathBinding.java?rev=375253&r1=375252&r2=375253&view=diff
==============================================================================
--- cocoon/trunk/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/binding/CustomJXPathBinding.java
(original)
+++ cocoon/trunk/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/binding/CustomJXPathBinding.java
Mon Feb  6 03:36:07 2006
@@ -15,6 +15,9 @@
  */
 package org.apache.cocoon.forms.binding;
 
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
 import org.apache.cocoon.forms.binding.JXPathBindingBuilderBase.CommonAttributes;
 import org.apache.cocoon.forms.formmodel.Widget;
 import org.apache.commons.jxpath.JXPathContext;
@@ -22,7 +25,7 @@
 /**
  * CustomJXPathBinding
  */
-public class CustomJXPathBinding extends JXPathBindingBase {
+public class CustomJXPathBinding extends JXPathBindingBase implements Serviceable {
     
     /** 
      * The id of the cforms widget
@@ -53,6 +56,7 @@
         this.widgetId = widgetId;
         this.xpath = xpath;
         this.wrappedBinding = wrappedBinding;
+        wrappedBinding.setXpath(xpath);
     }
     
     public String getXPath() { return xpath; }
@@ -69,10 +73,9 @@
      */
     public void doLoad(Widget frmModel, JXPathContext jxpc) throws BindingException {
         Widget selectedWidget = selectWidget(frmModel, this.widgetId);
-        JXPathContext context = jxpc.getRelativeContext(jxpc.getPointer(this.xpath));
-        
-        this.wrappedBinding.loadFormFromModel(selectedWidget, context);
-    }    
+
+        this.wrappedBinding.loadFormFromModel(selectedWidget, jxpc);
+    }
 
     /**
      * Delegates the actual saving operation to the provided Custom Binding Class
@@ -84,10 +87,16 @@
      */
     public void doSave(Widget frmModel, JXPathContext jxpc) throws BindingException {
         Widget selectedWidget = selectWidget(frmModel, this.widgetId);
-        JXPathContext context = jxpc.getRelativeContext(jxpc.getPointer(this.xpath));
-        
-        this.wrappedBinding.saveFormToModel(selectedWidget, context);
+
+        this.wrappedBinding.saveFormToModel(selectedWidget, jxpc);
     }
-    
 
+    /**
+     * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
+     */
+    public void service(ServiceManager manager) throws ServiceException {
+	    	if (wrappedBinding instanceof Serviceable) {
+            ((Serviceable) wrappedBinding).service(manager);
+        }
+    }
 }

Modified: cocoon/trunk/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/binding/CustomJXPathBindingBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/binding/CustomJXPathBindingBuilder.java?rev=375253&r1=375252&r2=375253&view=diff
==============================================================================
--- cocoon/trunk/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/binding/CustomJXPathBindingBuilder.java
(original)
+++ cocoon/trunk/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/binding/CustomJXPathBindingBuilder.java
Mon Feb  6 03:36:07 2006
@@ -17,6 +17,7 @@
 
 import java.lang.reflect.Method;
 
+import org.apache.cocoon.components.LifecycleHelper;
 import org.apache.cocoon.forms.binding.JXPathBindingManager.Assistant;
 import org.apache.cocoon.forms.util.DomHelper;
 import org.w3c.dom.Element;
@@ -128,6 +129,10 @@
 
             CustomJXPathBinding customBinding = 
                 new CustomJXPathBinding(commonAtts, widgetId, xpath, (AbstractCustomBinding)bindingInstance);
+
+            // Fire Avalon-setup for the custom binding
+            LifecycleHelper.setupComponent(customBinding, getLogger(), null, assistant.getServiceManager(),
null);
+
             return customBinding;
         } catch (BindingException e) {
             throw e;

Modified: cocoon/trunk/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/samples/bindings/CustomValueWrapBinding.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/samples/bindings/CustomValueWrapBinding.java?rev=375253&r1=375252&r2=375253&view=diff
==============================================================================
--- cocoon/trunk/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/samples/bindings/CustomValueWrapBinding.java
(original)
+++ cocoon/trunk/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/samples/bindings/CustomValueWrapBinding.java
Mon Feb  6 03:36:07 2006
@@ -53,7 +53,7 @@
      * Method signature and semantics complies to {@link AbstractCustomBinding#doLoad(Widget,
JXPathContext)}
      */
     public void doLoad(Widget frmModel, JXPathContext jxpc) throws BindingException {
-        String appValue = (String)jxpc.getValue(".");
+        String appValue = (String)jxpc.getValue(getXpath());
         String formValue= null;
         if (appValue.startsWith(this.prefix) 
                 && appValue.endsWith(suffix) 
@@ -72,7 +72,7 @@
      */
     public void doSave(Widget frmModel, JXPathContext jxpc) throws BindingException {
         Object formValue = frmModel.getValue();       
-        jxpc.setValue(".", "" + this.prefix + formValue + this.suffix);        
+        jxpc.setValue(getXpath(), "" + this.prefix + formValue + this.suffix);        
     }
     
     



Mime
View raw message