You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by br...@apache.org on 2003/07/24 14:39:18 UTC
cvs commit: cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding AggregateJXPathBinding.java AggregateJXPathBindingBuilder.java Binding.java ComposedJXPathBindingBase.java ContextJXPathBinding.java ContextJXPathBindingBuilder.java DeleteNodeJXPathBindingBuilder.java FieldJXPathBinding.java FieldJXPathBindingBuilder.java InsertBeanJXPathBinding.java InsertBeanJXPathBindingBuilder.java InsertNodeJXPathBinding.java InsertNodeJXPathBindingBuilder.java JXPathBindingBase.java JXPathBindingManager.java JXpathBindingBuilderBase.java RepeaterJXPathBinding.java RepeaterJXPathBindingBuilder.java SetAttributeJXPathBinding.java SetAttributeJXPathBindingBuilder.java
bruno 2003/07/24 05:39:18
Modified: src/blocks/woody/java/org/apache/cocoon/woody/binding
AggregateJXPathBinding.java
AggregateJXPathBindingBuilder.java Binding.java
ComposedJXPathBindingBase.java
ContextJXPathBinding.java
ContextJXPathBindingBuilder.java
DeleteNodeJXPathBindingBuilder.java
FieldJXPathBinding.java
FieldJXPathBindingBuilder.java
InsertBeanJXPathBinding.java
InsertBeanJXPathBindingBuilder.java
InsertNodeJXPathBinding.java
InsertNodeJXPathBindingBuilder.java
JXPathBindingBase.java JXPathBindingManager.java
JXpathBindingBuilderBase.java
RepeaterJXPathBinding.java
RepeaterJXPathBindingBuilder.java
SetAttributeJXPathBinding.java
SetAttributeJXPathBindingBuilder.java
Log:
various stuff:
* some reformatting
* throw exceptions instead of just logging when something goes wrong
* support non-string values and convertors in field binding
* use getLogger().isDebugEnabled() for expensive logging calls
Revision Changes Path
1.2 +11 -23 cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/AggregateJXPathBinding.java
Index: AggregateJXPathBinding.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/AggregateJXPathBinding.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AggregateJXPathBinding.java 22 Jul 2003 11:52:29 -0000 1.1
+++ AggregateJXPathBinding.java 24 Jul 2003 12:39:17 -0000 1.2
@@ -75,10 +75,7 @@
* @param xpath
* @param childBindings
*/
- public AggregateJXPathBinding(
- String widgetId,
- String xpath,
- JXPathBindingBase[] childBindings) {
+ public AggregateJXPathBinding(String widgetId, String xpath, JXPathBindingBase[] childBindings) {
super(childBindings);
this.widgetId = widgetId;
this.xpath = xpath;
@@ -90,13 +87,11 @@
* before continuing the binding over the child-bindings.
*/
public void loadFormFromModel(Widget frmModel, JXPathContext jxpc) {
-
- AggregateField aggregate =
- (AggregateField) frmModel.getWidget(this.widgetId);
- JXPathContext subContext =
- jxpc.getRelativeContext(jxpc.getPointer(this.xpath));
+ AggregateField aggregate = (AggregateField) frmModel.getWidget(this.widgetId);
+ JXPathContext subContext = jxpc.getRelativeContext(jxpc.getPointer(this.xpath));
super.loadFormFromModel(aggregate, subContext);
- getLogger().debug("done loading " + toString());
+ if (getLogger().isDebugEnabled())
+ getLogger().debug("done loading " + toString());
}
/**
@@ -104,22 +99,15 @@
* narrows the scope on the object-model to the member xpath-context
* before continuing the binding over the child-bindings.
*/
- public void saveFormToModel(Widget frmModel, JXPathContext jxpc) {
-
- AggregateField aggregate =
- (AggregateField) frmModel.getWidget(this.widgetId);
- JXPathContext subContext =
- jxpc.getRelativeContext(jxpc.getPointer(this.xpath));
+ public void saveFormToModel(Widget frmModel, JXPathContext jxpc) throws BindingException {
+ AggregateField aggregate = (AggregateField) frmModel.getWidget(this.widgetId);
+ JXPathContext subContext = jxpc.getRelativeContext(jxpc.getPointer(this.xpath));
super.saveFormToModel(aggregate, subContext);
- getLogger().debug("done saving " + toString());
+ if (getLogger().isDebugEnabled())
+ getLogger().debug("done saving " + toString());
}
public String toString() {
- return "AggregateJXPathBinding [widget="
- + this.widgetId
- + ", xpath="
- + this.xpath
- + "]";
+ return "AggregateJXPathBinding [widget=" + this.widgetId + ", xpath=" + this.xpath + "]";
}
-
}
1.2 +7 -14 cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/AggregateJXPathBindingBuilder.java
Index: AggregateJXPathBindingBuilder.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/AggregateJXPathBindingBuilder.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AggregateJXPathBindingBuilder.java 22 Jul 2003 11:52:30 -0000 1.1
+++ AggregateJXPathBindingBuilder.java 24 Jul 2003 12:39:17 -0000 1.2
@@ -67,27 +67,20 @@
public class AggregateJXPathBindingBuilder
extends JXpathBindingBuilderBase {
- /**
- * @see org.outerj.woody.binding.BindingBuilder#buildBinding(org.w3c.dom.Element, org.outerj.woody.binding.BuilderAssistant)
- */
- public JXPathBindingBase buildBinding(
- Element bindingElm,
- JXPathBindingManager.Assistant assistant) {
+ public JXPathBindingBase buildBinding(Element bindingElm, JXPathBindingManager.Assistant assistant)
+ throws BindingException {
try {
String xpath = DomHelper.getAttribute(bindingElm, "path");
String widgetId = DomHelper.getAttribute(bindingElm, "id");
- JXPathBindingBase[] childBindings =
- assistant.makeChildBindings(bindingElm);
+ JXPathBindingBase[] childBindings = assistant.makeChildBindings(bindingElm);
- AggregateJXPathBinding aggregateBinding =
- new AggregateJXPathBinding(widgetId, xpath, childBindings);
+ AggregateJXPathBinding aggregateBinding = new AggregateJXPathBinding(widgetId, xpath, childBindings);
return aggregateBinding;
+ } catch (BindingException e) {
+ throw e;
} catch (Exception e) {
- getLogger().warn(
- "Error building an aggregate field binding.",
- e);
- return null;
+ throw new BindingException("Error building aggregate field binding defined at " + DomHelper.getLocation(bindingElm), e);
}
}
}
1.2 +1 -1 cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/Binding.java
Index: Binding.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/Binding.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Binding.java 22 Jul 2003 11:52:30 -0000 1.1
+++ Binding.java 24 Jul 2003 12:39:17 -0000 1.2
@@ -71,5 +71,5 @@
* @param frmModel
* @param objModel
*/
- public void saveFormToModel(Widget frmModel, Object objModel);
+ public void saveFormToModel(Widget frmModel, Object objModel) throws BindingException;
}
1.2 +1 -1 cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/ComposedJXPathBindingBase.java
Index: ComposedJXPathBindingBase.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/ComposedJXPathBindingBase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ComposedJXPathBindingBase.java 22 Jul 2003 11:52:30 -0000 1.1
+++ ComposedJXPathBindingBase.java 24 Jul 2003 12:39:17 -0000 1.2
@@ -101,7 +101,7 @@
* Actively performs the binding from the Woody-form to the ObjectModel
* by passing the task onto it's children.
*/
- public void saveFormToModel(Widget frmModel, JXPathContext jxpc) {
+ public void saveFormToModel(Widget frmModel, JXPathContext jxpc) throws BindingException {
if (this.subBindings != null) {
int size = this.subBindings.length;
for (int i = 0; i < size; i++) {
1.2 +10 -15 cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/ContextJXPathBinding.java
Index: ContextJXPathBinding.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/ContextJXPathBinding.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ContextJXPathBinding.java 22 Jul 2003 11:52:30 -0000 1.1
+++ ContextJXPathBinding.java 24 Jul 2003 12:39:17 -0000 1.2
@@ -61,18 +61,14 @@
public class ContextJXPathBinding extends ComposedJXPathBindingBase {
/**
- * the relative contextPath for the sub-bindings of this context */
+ * the relative contextPath for the sub-bindings of this context
+ */
private final String xpath;
/**
* Constructs ContextJXPathBinding for the specified xpath sub-context
- *
- * @param contextPath
- * @param childBindings
*/
- public ContextJXPathBinding(
- String contextPath,
- JXPathBindingBase[] childBindings) {
+ public ContextJXPathBinding(String contextPath, JXPathBindingBase[] childBindings) {
super(childBindings);
this.xpath = contextPath;
}
@@ -82,25 +78,24 @@
* context to the Woody-form.
*/
public void loadFormFromModel(Widget frmModel, JXPathContext jxpc) {
- JXPathContext subContext =
- jxpc.getRelativeContext(jxpc.getPointer(this.xpath));
+ JXPathContext subContext = jxpc.getRelativeContext(jxpc.getPointer(this.xpath));
super.loadFormFromModel(frmModel, subContext);
- getLogger().debug("done loading " + toString());
+ if (getLogger().isDebugEnabled())
+ getLogger().debug("done loading " + toString());
}
/**
* Actively performs the binding from the Woody-form to the ObjectModel
* wrapped in a jxpath context.
*/
- public void saveFormToModel(Widget frmModel, JXPathContext jxpc) {
- JXPathContext subContext =
- jxpc.getRelativeContext(jxpc.getPointer(this.xpath));
+ public void saveFormToModel(Widget frmModel, JXPathContext jxpc) throws BindingException {
+ JXPathContext subContext = jxpc.getRelativeContext(jxpc.getPointer(this.xpath));
super.saveFormToModel(frmModel, subContext);
- getLogger().debug("done saving " + toString());
+ if (getLogger().isDebugEnabled())
+ getLogger().debug("done saving " + toString());
}
public String toString() {
return "ContextJXPathBinding [xpath=" + this.xpath + "]";
}
-
}
1.2 +7 -9 cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/ContextJXPathBindingBuilder.java
Index: ContextJXPathBindingBuilder.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/ContextJXPathBindingBuilder.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ContextJXPathBindingBuilder.java 22 Jul 2003 11:52:30 -0000 1.1
+++ ContextJXPathBindingBuilder.java 24 Jul 2003 12:39:17 -0000 1.2
@@ -70,22 +70,20 @@
* Creates an instance of ContextJXPathBinding with the configured
* path and nested child bindings from the declarations in the bindingElm
*/
- public JXPathBindingBase buildBinding(
- Element bindingElm,
- JXPathBindingManager.Assistant assistant) {
+ public JXPathBindingBase buildBinding(Element bindingElm,
+ JXPathBindingManager.Assistant assistant) throws BindingException {
try {
String xpath = DomHelper.getAttribute(bindingElm, "path");
- JXPathBindingBase[] childBindings =
- assistant.makeChildBindings(bindingElm);
+ JXPathBindingBase[] childBindings = assistant.makeChildBindings(bindingElm);
- ContextJXPathBinding contextBinding =
- new ContextJXPathBinding(xpath, childBindings);
+ ContextJXPathBinding contextBinding = new ContextJXPathBinding(xpath, childBindings);
return contextBinding;
+ } catch (BindingException e) {
+ throw e;
} catch (Exception e) {
- getLogger().warn("Error building a field binding.", e);
- return null;
+ throw new BindingException("Error building context binding defined at " + DomHelper.getLocation(bindingElm), e);
}
}
}
1.2 +1 -3 cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/DeleteNodeJXPathBindingBuilder.java
Index: DeleteNodeJXPathBindingBuilder.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/DeleteNodeJXPathBindingBuilder.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DeleteNodeJXPathBindingBuilder.java 22 Jul 2003 11:52:30 -0000 1.1
+++ DeleteNodeJXPathBindingBuilder.java 24 Jul 2003 12:39:17 -0000 1.2
@@ -69,9 +69,7 @@
/**
* Creates an instance of {@link DeleteNodeJXPathBinding}.
*/
- public JXPathBindingBase buildBinding(
- Element bindingElm,
- Assistant assistant) {
+ public JXPathBindingBase buildBinding(Element bindingElm, Assistant assistant) {
return new DeleteNodeJXPathBinding();
}
1.2 +74 -62 cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/FieldJXPathBinding.java
Index: FieldJXPathBinding.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/FieldJXPathBinding.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FieldJXPathBinding.java 22 Jul 2003 11:52:30 -0000 1.1
+++ FieldJXPathBinding.java 24 Jul 2003 12:39:17 -0000 1.2
@@ -53,120 +53,132 @@
import org.apache.avalon.framework.logger.Logger;
import org.apache.cocoon.woody.formmodel.Widget;
import org.apache.cocoon.woody.formmodel.Field;
+import org.apache.cocoon.woody.datatype.convertor.Convertor;
import org.apache.commons.jxpath.JXPathContext;
+import org.apache.commons.jxpath.JXPathException;
-///**
-// * Represents a Binding class for the Woody block that maps onto
-// * a <bnd:field> element of the binding config.
-// * The purpose of a this is to map a specific widget's value to a jxpath
-// * accessible property of the objectModel.
-// */
+import java.util.Locale;
/**
- * FieldJXPathBinding provides an implementation of a {@link Binding}
- * that loads and saves the information behind a specific xpath expresion
+ * FieldJXPathBinding provides an implementation of a {@link Binding}
+ * that loads and saves the information behind a specific xpath expresion
* (pointing to an attribute or text-node) to and from a specific Woody
- * widget as identified by its id.
+ * widget as identified by its id.
*/
public class FieldJXPathBinding extends JXPathBindingBase {
- /**
- * The xpath expression to the objectModel property */
+ /**
+ * The xpath expression to the objectModel property
+ */
private final String xpath;
- /**
- * The id of the Woody form-widget */
+ /**
+ * The id of the Woody form-widget
+ */
private final String fieldId;
- /**
- * Flag indicating if the objectModel-property can be altered or not */
+ /**
+ * Flag indicating if the objectModel-property can be altered or not
+ */
private final boolean readonly;
- /**
- * Flag indicating if the objectModel-property can be altered or not */
+ /**
+ * Flag indicating if the objectModel-property can be altered or not
+ */
private final JXPathBindingBase updateBinding;
/**
- * Constructs FieldJXPathBinding
+ * Optional convertor to convert values to and from strings when setting or reading
+ * the from the model. Especially used in combination with XML models where everything
+ * are strings.
+ */
+ private final Convertor convertor;
+
+ /**
+ * The locale to pass to the {@link #convertor}.
+ */
+ private final Locale convertorLocale;
+
+ /**
+ * Constructs FieldJXPathBinding.
+ *
+ * @param convertor may be null
*/
- public FieldJXPathBinding(
- String widgetId,
- String xpath,
- boolean readonly,
- JXPathBindingBase[] updateBindings) {
+ public FieldJXPathBinding(String widgetId, String xpath, boolean readonly, JXPathBindingBase[] updateBindings,
+ Convertor convertor, Locale convertorLocale) {
this.fieldId = widgetId;
this.xpath = xpath;
this.readonly = readonly;
this.updateBinding = new ComposedJXPathBindingBase(updateBindings);
+ this.convertor = convertor;
+ this.convertorLocale = convertorLocale;
}
/**
- * Actively performs the binding from the ObjectModel wrapped in a jxpath
+ * Actively performs the binding from the ObjectModel wrapped in a jxpath
* context to the Woody-form-widget specified in this object.
*/
public void loadFormFromModel(Widget frmModel, JXPathContext jxpc) {
try {
Field fld = (Field) frmModel.getWidget(this.fieldId);
- // TODO here we need to use the dataconversion in the future
- String value = (String) jxpc.getValue(this.xpath);
+ Object value = jxpc.getValue(this.xpath);
+
+ if (convertor != null)
+ value = convertor.convertFromString((String)value, convertorLocale, null);
+
fld.setValue(value);
- getLogger().debug(
- "done loading " + toString() + " -- value= " + value);
+
+ if (getLogger().isDebugEnabled())
+ getLogger().debug("done loading " + toString() + " -- value= " + value);
} catch (Exception e) {
- getLogger().warn(
- "JXPath failed to find value for " + this.xpath,
- e);
+ getLogger().warn("JXPath failed to find value for " + this.xpath, e);
}
}
/**
- * Actively performs the binding from the Woody-form to the ObjectModel
+ * Actively performs the binding from the Woody-form to the ObjectModel
* wrapped in a jxpath context
*/
- public void saveFormToModel(Widget frmModel, JXPathContext jxpc) {
+ public void saveFormToModel(Widget frmModel, JXPathContext jxpc) throws BindingException {
if (!this.readonly) {
try {
Field fld = (Field) frmModel.getWidget(this.fieldId);
- // TODO here we need some dataconversion in the future
- String value = (String) fld.getValue();
- String oldValue = (String) jxpc.getValue(this.xpath);
- getLogger().debug(
- "value= " + value + "-- oldvalue=" + oldValue);
+ Object value = fld.getValue();
+ if (value != null && convertor != null)
+ value = convertor.convertToString(value, convertorLocale, null);
+ Object oldValue = jxpc.getValue(this.xpath);
+ if (getLogger().isDebugEnabled())
+ getLogger().debug("value= " + value + "-- oldvalue=" + oldValue);
boolean update = false;
- if (value != oldValue
- && value != null
- && !value.equals(oldValue)) {
+ if ((value == null && oldValue != null) || value != null && !value.equals(oldValue)) {
+ // first update the value itself
jxpc.setValue(this.xpath, value);
- JXPathContext subContext =
- jxpc.getRelativeContext(
- jxpc.getPointer(this.xpath));
- this.updateBinding.saveFormToModel(
- frmModel,
- subContext);
+
+ // now perform any other bindings that need to be performed when the value is updated
+ JXPathContext subContext = null;
+ try {
+ subContext = jxpc.getRelativeContext(jxpc.getPointer(this.xpath));
+ } catch (JXPathException e) {
+ // if the value has been set to null and the underlying model is a bean, then
+ // JXPath will not be able to create a relative context
+ if (getLogger().isDebugEnabled())
+ getLogger().debug("(Ignorable) problem binding field " + fld.getFullyQualifiedId(), e);
+ }
+ if (subContext != null)
+ this.updateBinding.saveFormToModel(frmModel, subContext);
update = true;
}
- getLogger().debug(
- "done saving "
- + toString()
- + " -- value= "
- + value
- + " -- on-update == "
- + update);
+ if (getLogger().isDebugEnabled())
+ getLogger().debug("done saving " + toString() + " -- value= " + value + " -- on-update == " + update);
} catch (Exception e) {
- getLogger().warn(
- "JXPath failed to find value for " + this.xpath,
- e);
+ throw new BindingException("Problem binding field " + this.fieldId + " (parent = \"" + frmModel.getFullyQualifiedId() + "\") to xpath " + this.xpath + " (context xpath = \"" + jxpc.getContextPointer().asPath() + "\")", e);
}
}
}
public String toString() {
- return "FieldJXPathBinding [widget="
- + this.fieldId
- + ", xpath="
- + this.xpath
- + "]";
+ return "FieldJXPathBinding [widget=" + this.fieldId + ", xpath=" + this.xpath + "]";
}
public void enableLogging(Logger logger) {
1.2 +24 -21 cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/FieldJXPathBindingBuilder.java
Index: FieldJXPathBindingBuilder.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/FieldJXPathBindingBuilder.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FieldJXPathBindingBuilder.java 22 Jul 2003 11:52:30 -0000 1.1
+++ FieldJXPathBindingBuilder.java 24 Jul 2003 12:39:17 -0000 1.2
@@ -51,8 +51,13 @@
package org.apache.cocoon.woody.binding;
import org.apache.cocoon.woody.util.DomHelper;
+import org.apache.cocoon.woody.Constants;
+import org.apache.cocoon.woody.datatype.convertor.Convertor;
+import org.apache.cocoon.i18n.I18nUtils;
import org.w3c.dom.Element;
+import java.util.Locale;
+
/**
* FieldJXPathBindingBuilder provides a helper class for the Factory
* implemented in {@link JXPathBindingManager} that helps construct the
@@ -74,38 +79,36 @@
* Creates an instance of {@link FieldJXPathBinding} based on the attributes
* and nested configuration of the provided bindingElm.
*/
- public JXPathBindingBase buildBinding(
- Element bindingElm,
- JXPathBindingManager.Assistant assistant) {
+ public JXPathBindingBase buildBinding(Element bindingElm, JXPathBindingManager.Assistant assistant) throws BindingException {
try {
- boolean readonly =
- DomHelper.getAttributeAsBoolean(
- bindingElm,
- "readonly",
- false);
+ boolean readonly = DomHelper.getAttributeAsBoolean(bindingElm, "readonly", false);
String xpath = DomHelper.getAttribute(bindingElm, "path");
String widgetId = DomHelper.getAttribute(bindingElm, "id");
Element updateWrapElement =
- DomHelper.getChildElement(
- bindingElm,
- BindingManager.NAMESPACE,
- "on-update");
- JXPathBindingBase[] updateBindings =
- assistant.makeChildBindings(updateWrapElement);
+ DomHelper.getChildElement(bindingElm, BindingManager.NAMESPACE, "on-update");
+ JXPathBindingBase[] updateBindings = assistant.makeChildBindings(updateWrapElement);
+
+ Convertor convertor = null;
+ Locale convertorLocale = Locale.US;
+ Element convertorEl = DomHelper.getChildElement(bindingElm, Constants.WD_NS, "convertor");
+ if (convertorEl != null) {
+ String datatype = DomHelper.getAttribute(convertorEl, "datatype");
+ String localeStr = convertorEl.getAttribute("datatype");
+ if (!localeStr.equals(""))
+ convertorLocale = I18nUtils.parseLocale(localeStr);
+ convertor = assistant.getDatatypeManager().createConvertor(datatype, convertorEl);
+ }
FieldJXPathBinding fieldBinding =
- new FieldJXPathBinding(
- widgetId,
- xpath,
- readonly,
- updateBindings);
+ new FieldJXPathBinding(widgetId, xpath, readonly, updateBindings, convertor, convertorLocale);
return fieldBinding;
+ } catch (BindingException e) {
+ throw e;
} catch (Exception e) {
- getLogger().warn("Error building a field binding.", e);
- return null;
+ throw new BindingException("Error building binding defined at " + DomHelper.getLocation(bindingElm), e);
}
}
}
1.2 +13 -27 cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/InsertBeanJXPathBinding.java
Index: InsertBeanJXPathBinding.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/InsertBeanJXPathBinding.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- InsertBeanJXPathBinding.java 23 Jul 2003 15:22:07 -0000 1.1
+++ InsertBeanJXPathBinding.java 24 Jul 2003 12:39:17 -0000 1.2
@@ -56,6 +56,7 @@
import org.apache.commons.jxpath.AbstractFactory;
import org.apache.commons.jxpath.JXPathContext;
import org.apache.commons.jxpath.Pointer;
+import org.apache.avalon.framework.CascadingRuntimeException;
/**
* InsertBeanJXPathBinding provides an implementation of a {@link Binding}
@@ -73,7 +74,6 @@
/**
* Constructs InsertBeanJXPathBinding
- * @param className
*/
public InsertBeanJXPathBinding(String className, String addMethod) {
this.className = className;
@@ -93,54 +93,40 @@
* The factory will insert a new instance of the specified bean (classname)
* inside this object into the target objectmodel.
*/
- public void saveFormToModel(Widget frmModel, JXPathContext jxpc) {
+ public void saveFormToModel(Widget frmModel, JXPathContext jxpc) throws BindingException {
jxpc.setFactory(new AbstractFactory() {
- public boolean createObject(
- JXPathContext context,
- Pointer pointer,
- Object parent,
- String name,
- int index) {
-
+ public boolean createObject(JXPathContext context, Pointer pointer,
+ Object parent, String name, int index) {
try {
Object[] args = new Object[1];
Class[] argTypes = new Class[1];
// instantiate the new object
- argTypes[0] =
- Class.forName(InsertBeanJXPathBinding.this.className);
+ argTypes[0] = Class.forName(InsertBeanJXPathBinding.this.className);
args[0] = argTypes[0].newInstance();
// lookup the named method on the parent
Method addMethod =
- parent.getClass().getMethod(
- InsertBeanJXPathBinding.this.addMethodName,
- argTypes);
+ parent.getClass().getMethod(InsertBeanJXPathBinding.this.addMethodName, argTypes);
// invoke this method with this new beast.
addMethod.invoke(parent, args);
-
- InsertBeanJXPathBinding.this.getLogger().debug(
- "InsertBean jxpath factory executed for index."
- + index);
+
+ if (getLogger().isDebugEnabled())
+ getLogger().debug("InsertBean jxpath factory executed for index " + index);
return true;
} catch (Exception e) {
- InsertBeanJXPathBinding.this.getLogger().warn("InsertBean jxpath factory failed.", e);
- return false;
+ throw new CascadingRuntimeException("InsertBean jxpath factory failed.", e);
}
}
});
- getLogger().debug(
- "done registered factory for inserting node -- " + toString());
+ if (getLogger().isDebugEnabled())
+ getLogger().debug("done registered factory for inserting node -- " + toString());
}
public String toString() {
- return "InsertBeanJXPathBinding [for class "
- + this.className
- + " to addMethod "
- + this.addMethodName
- + "]";
+ return "InsertBeanJXPathBinding [for class " + this.className + " to addMethod " + this.addMethodName + "]";
}
}
1.2 +4 -5 cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/InsertBeanJXPathBindingBuilder.java
Index: InsertBeanJXPathBindingBuilder.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/InsertBeanJXPathBindingBuilder.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- InsertBeanJXPathBindingBuilder.java 23 Jul 2003 15:22:07 -0000 1.1
+++ InsertBeanJXPathBindingBuilder.java 24 Jul 2003 12:39:17 -0000 1.2
@@ -70,9 +70,7 @@
* Creates an instance of {@link InsertBeanJXPathBinding} configured
* with the nested template of the bindingElm.
*/
- public JXPathBindingBase buildBinding(
- Element bindingElm,
- Assistant assistant) {
+ public JXPathBindingBase buildBinding(Element bindingElm, Assistant assistant) throws BindingException {
try {
String className =
@@ -81,9 +79,10 @@
DomHelper.getAttribute(bindingElm, "addmethod");
return new InsertBeanJXPathBinding(className, addMethod);
+ } catch (BindingException e) {
+ throw e;
} catch (Exception e) {
- getLogger().warn("Error building a insert-bean binding.", e);
- return null;
+ throw new BindingException("Error building a insert-bean binding defined at " + DomHelper.getLocation(bindingElm), e);
}
}
1.2 +7 -8 cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/InsertNodeJXPathBinding.java
Index: InsertNodeJXPathBinding.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/InsertNodeJXPathBinding.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- InsertNodeJXPathBinding.java 22 Jul 2003 11:52:30 -0000 1.1
+++ InsertNodeJXPathBinding.java 24 Jul 2003 12:39:17 -0000 1.2
@@ -74,7 +74,6 @@
/**
* Constructs InsertNodeJXPathBinding
- * @param domTemplate
*/
public InsertNodeJXPathBinding(DocumentFragment domTemplate) {
this.template = domTemplate;
@@ -93,9 +92,7 @@
* The factory will inserts a clone of the 'template' DocumentFragment
* inside this object into the target objectmodel.
*/
- public void saveFormToModel(
- Widget frmModel,
- JXPathContext jxpc) {
+ public void saveFormToModel(Widget frmModel, JXPathContext jxpc) {
jxpc.setFactory(new AbstractFactory() {
public boolean createObject(JXPathContext context, Pointer pointer,
@@ -105,13 +102,15 @@
Document targetDoc = parentNode.getOwnerDocument();
Node toInsert = targetDoc.importNode(InsertNodeJXPathBinding.this.template, true);
parentNode.appendChild(toInsert);
-
- InsertNodeJXPathBinding.this.getLogger().debug("InsertNode jxpath factory executed for index." + index);
+
+ if (getLogger().isDebugEnabled())
+ getLogger().debug("InsertNode jxpath factory executed for index." + index);
return true;
}
});
-
- getLogger().debug("done registered factory for inserting node -- " + toString());
+
+ if (getLogger().isDebugEnabled())
+ getLogger().debug("done registered factory for inserting node -- " + toString());
}
public String toString() {
1.2 +3 -3 cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/InsertNodeJXPathBindingBuilder.java
Index: InsertNodeJXPathBindingBuilder.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/InsertNodeJXPathBindingBuilder.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- InsertNodeJXPathBindingBuilder.java 22 Jul 2003 11:52:30 -0000 1.1
+++ InsertNodeJXPathBindingBuilder.java 24 Jul 2003 12:39:17 -0000 1.2
@@ -53,6 +53,7 @@
import org.w3c.dom.DocumentFragment;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
+import org.apache.cocoon.woody.util.DomHelper;
/**
* InsertNodeJXPathBindingBuilder provides a helper class for the Factory
@@ -75,7 +76,7 @@
*/
public JXPathBindingBase buildBinding(
Element bindingElm,
- JXPathBindingManager.Assistant assistant) {
+ JXPathBindingManager.Assistant assistant) throws BindingException {
try {
// TODO have src attribute to point to extermal template in stead of
@@ -92,8 +93,7 @@
return new InsertNodeJXPathBinding(domTemplate);
} catch (Exception e) {
- getLogger().warn("Error building a insert-node binding.", e);
- return null;
+ throw new BindingException("Error building the insert-node binding defined at " + DomHelper.getLocation(bindingElm), e);
}
}
}
1.2 +5 -8 cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/JXPathBindingBase.java
Index: JXPathBindingBase.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/JXPathBindingBase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JXPathBindingBase.java 22 Jul 2003 11:52:30 -0000 1.1
+++ JXPathBindingBase.java 24 Jul 2003 12:39:17 -0000 1.2
@@ -63,7 +63,8 @@
public abstract class JXPathBindingBase implements Binding, LogEnabled {
/**
- * Avalon Logger to use in all subclasses. */
+ * Avalon Logger to use in all subclasses.
+ */
private Logger logger;
/**
@@ -71,9 +72,7 @@
* then on generic objects.
* Abstract method that subclasses need to implement for specific activity.
*/
- public abstract void loadFormFromModel(
- Widget frmModel,
- JXPathContext jxpc);
+ public abstract void loadFormFromModel(Widget frmModel, JXPathContext jxpc);
/**
* Hooks up with the more generic Binding of any objectModel by wrapping
@@ -95,16 +94,14 @@
* then on generic objects.
* Abstract method that subclasses need to implement for specific activity.
*/
- public abstract void saveFormToModel(
- Widget frmModel,
- JXPathContext jxpc);
+ public abstract void saveFormToModel(Widget frmModel, JXPathContext jxpc) throws BindingException;
/**
* Hooks up with the more generic Binding of any objectModel by wrapping
* it up in a JXPathContext object and then transfering control over to
* the new overloaded version of this method.
*/
- public void saveFormToModel(Widget frmModel, Object objModel) {
+ public void saveFormToModel(Widget frmModel, Object objModel) throws BindingException {
JXPathContext jxpc;
if (!(objModel instanceof JXPathContext)) {
jxpc = JXPathContext.newContext(objModel);
1.3 +38 -42 cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/JXPathBindingManager.java
Index: JXPathBindingManager.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/JXPathBindingManager.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JXPathBindingManager.java 23 Jul 2003 15:26:14 -0000 1.2
+++ JXPathBindingManager.java 24 Jul 2003 12:39:17 -0000 1.3
@@ -56,8 +56,13 @@
import org.apache.avalon.framework.logger.LogEnabled;
import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.activity.Disposable;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.woody.util.DomHelper;
+import org.apache.cocoon.woody.datatype.DatatypeManager;
import org.apache.excalibur.source.Source;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -68,14 +73,15 @@
* by usage of the <a href="http://jakarta.apache.org/commons/jxpath/index.html">
* JXPath package</a>.
*/
-public class JXPathBindingManager implements BindingManager, LogEnabled {
+public class JXPathBindingManager implements BindingManager, LogEnabled, Serviceable, Disposable {
//TODO caching of the Bindings.
- /**
- * Avalon logger to use. */
private Logger logger;
+ private DatatypeManager datatypeManager;
+ private ServiceManager serviceManager;
+
/**
* Map of specific builders for the different elements in the
* Binding config.
@@ -108,6 +114,11 @@
new InsertBeanJXPathBindingBuilder());
}
+ public void service(ServiceManager serviceManager) throws ServiceException {
+ this.serviceManager = serviceManager;
+ this.datatypeManager = (DatatypeManager)serviceManager.lookup(DatatypeManager.ROLE);
+ }
+
public Binding createBinding(Source bindSrc)
throws ProcessingException {
try {
@@ -115,20 +126,12 @@
DomHelper.parse(new InputSource(bindSrc.getURI()));
Element rootElm = doc.getDocumentElement();
JXPathBindingBase newBinding = null;
- if (BindingManager
- .NAMESPACE
- .equals(rootElm.getNamespaceURI())) {
- newBinding =
- getBuilderAssistant()
- .getBindingForConfigurationElement(
- rootElm);
-
+ if (BindingManager.NAMESPACE.equals(rootElm.getNamespaceURI())) {
+ newBinding = getBuilderAssistant().getBindingForConfigurationElement(rootElm);
newBinding.enableLogging(getLogger());
- getLogger().debug(
- "Creation of new Binding finished. " + newBinding);
+ getLogger().debug("Creation of new Binding finished. " + newBinding);
} else {
- getLogger().debug(
- "Root Element of said binding file is in wrong namespace.");
+ getLogger().debug("Root Element of said binding file is in wrong namespace.");
}
return newBinding;
} catch (Exception e) {
@@ -156,7 +159,11 @@
return new Assistant();
}
- /**
+ public void dispose() {
+ serviceManager.release(datatypeManager);
+ }
+
+ /**
* Assistant Inner class discloses enough features to the created
* childBindings to recursively
*
@@ -176,50 +183,39 @@
/**
* Creates a {@link Binding} folowing the specification in the
* provided config element.
- *
- * @param configElm
- * @return
*/
- public JXPathBindingBase getBindingForConfigurationElement(Element configElm) {
+ public JXPathBindingBase getBindingForConfigurationElement(Element configElm) throws BindingException {
String bindingType = configElm.getLocalName();
- JXPathBindingManager.this.getLogger().debug(
- "build binding for config elm " + bindingType);
- JXpathBindingBuilderBase bindingBuilder =
- getBindingBuilder(bindingType);
- JXPathBindingBase childBinding =
- (JXPathBindingBase) bindingBuilder.buildBinding(
- configElm,
- this);
+ if (getLogger().isDebugEnabled())
+ JXPathBindingManager.this.getLogger().debug("build binding for config elm " + bindingType);
+ JXpathBindingBuilderBase bindingBuilder = getBindingBuilder(bindingType);
+ JXPathBindingBase childBinding = bindingBuilder.buildBinding(configElm, this);
return childBinding;
}
/**
* Makes an array of childBindings for the child-elements of the
- * provided cinfiguration element.
- *
- * @param parentElement
- * @return
+ * provided configuration element.
*/
- public JXPathBindingBase[] makeChildBindings(Element parentElement) {
+ public JXPathBindingBase[] makeChildBindings(Element parentElement) throws BindingException {
if (parentElement == null) {
return null;
}
- Element[] childElements =
- DomHelper.getChildElements(
- parentElement,
- BindingManager.NAMESPACE);
- if (childElements != null) {
- JXPathBindingBase[] childBindings =
- new JXPathBindingBase[childElements.length];
+ Element[] childElements = DomHelper.getChildElements(parentElement, BindingManager.NAMESPACE);
+ if (childElements.length > 0) {
+ JXPathBindingBase[] childBindings = new JXPathBindingBase[childElements.length];
for (int i = 0; i < childElements.length; i++) {
- childBindings[i] =
- getBindingForConfigurationElement(childElements[i]);
+ childBindings[i] = getBindingForConfigurationElement(childElements[i]);
}
return childBindings;
} else {
return null;
}
+ }
+
+ public DatatypeManager getDatatypeManager() {
+ return datatypeManager;
}
}
1.2 +1 -1 cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/JXpathBindingBuilderBase.java
Index: JXpathBindingBuilderBase.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/JXpathBindingBuilderBase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JXpathBindingBuilderBase.java 22 Jul 2003 11:52:30 -0000 1.1
+++ JXpathBindingBuilderBase.java 24 Jul 2003 12:39:17 -0000 1.2
@@ -88,6 +88,6 @@
*/
public abstract JXPathBindingBase buildBinding(
Element bindingElm,
- JXPathBindingManager.Assistant assistant);
+ JXPathBindingManager.Assistant assistant) throws BindingException;
}
1.2 +25 -49 cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/RepeaterJXPathBinding.java
Index: RepeaterJXPathBinding.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/RepeaterJXPathBinding.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- RepeaterJXPathBinding.java 22 Jul 2003 11:52:30 -0000 1.1
+++ RepeaterJXPathBinding.java 24 Jul 2003 12:39:17 -0000 1.2
@@ -82,26 +82,19 @@
/**
* Constructs RepeaterJXPathBinding
*/
- public RepeaterJXPathBinding(
- String repeaterId,
- String repeaterPath,
- String rowPath,
- String uniqueRowId,
- String uniqueRowPath,
- JXPathBindingBase[] childBindings,
- JXPathBindingBase insertBinding,
- JXPathBindingBase[] deleteBindings) {
+ public RepeaterJXPathBinding(String repeaterId, String repeaterPath, String rowPath, String uniqueRowId,
+ String uniqueRowPath, JXPathBindingBase[] childBindings,
+ JXPathBindingBase insertBinding, JXPathBindingBase[] deleteBindings) {
this.repeaterId = repeaterId;
this.repeaterPath = repeaterPath;
this.rowPath = rowPath;
this.uniqueRowId = uniqueRowId;
this.uniqueRowPath = uniqueRowPath;
this.uniqueFieldBinding =
- new FieldJXPathBinding(uniqueRowId, uniqueRowPath, true, null);
+ new FieldJXPathBinding(uniqueRowId, uniqueRowPath, true, null, null, null);
this.rowBinding = new ComposedJXPathBindingBase(childBindings);
this.insertRowBinding = insertBinding;
- this.deleteRowBinding =
- new ComposedJXPathBindingBase(deleteBindings);
+ this.deleteRowBinding = new ComposedJXPathBindingBase(deleteBindings);
}
@@ -109,19 +102,14 @@
* Binds the unique-id of the repeated rows, and narrows the context on
* objectModelContext and Repeater to the repeated rows before handing
* over to the actual binding-children.
- *
- * @param frmModel
- * @param jxpc
*/
public void loadFormFromModel(Widget frmModel, JXPathContext jxpc) {
// Find the repeater
Repeater repeater = (Repeater) frmModel.getWidget(this.repeaterId);
// build a jxpath iterator for pointers
- JXPathContext repeaterContext =
- jxpc.getRelativeContext(jxpc.getPointer(this.repeaterPath));
- Iterator rowPointers =
- repeaterContext.iteratePointers(this.rowPath);
+ JXPathContext repeaterContext = jxpc.getRelativeContext(jxpc.getPointer(this.repeaterPath));
+ Iterator rowPointers = repeaterContext.iteratePointers(this.rowPath);
//iterate through it
while (rowPointers.hasNext()) {
@@ -130,14 +118,15 @@
// make a jxpath ObjectModelSubcontext on the iterated element
Pointer jxp = (Pointer) rowPointers.next();
- JXPathContext rowContext =
- repeaterContext.getRelativeContext(jxp);
+ JXPathContext rowContext = repeaterContext.getRelativeContext(jxp);
// hand it over to children
this.uniqueFieldBinding.loadFormFromModel(thisRow, rowContext);
this.rowBinding.loadFormFromModel(thisRow, rowContext);
}
- getLogger().debug("done loading rows " + toString());
+
+ if (getLogger().isDebugEnabled())
+ getLogger().debug("done loading rows " + toString());
}
@@ -146,7 +135,7 @@
* updated, inserted or removed. Depending on what happened the appropriate
* child-bindings are alowed to visit the narrowed contexts.
*/
- public void saveFormToModel(Widget frmModel, JXPathContext jxpc) {
+ public void saveFormToModel(Widget frmModel, JXPathContext jxpc) throws BindingException {
// Find the repeater
Repeater repeater = (Repeater) frmModel.getWidget(this.repeaterId);
@@ -178,13 +167,10 @@
repeaterContext.getRelativeContext(jxp);
//TODO future might need data-conversion here
- String matchId =
- (String) rowContext.getValue(this.uniqueRowPath);
+ String matchId = (String) rowContext.getValue(this.uniqueRowPath);
if (rowIdValue.equals(matchId)) {
// match! --> bind to children
- this.rowBinding.saveFormToModel(
- thisRow,
- rowContext);
+ this.rowBinding.saveFormToModel(thisRow, rowContext);
// --> store rowIdValue in list of updatedRowIds
updatedRowIds.add(rowIdValue);
break;
@@ -197,15 +183,12 @@
}
//again iterate nodes for deletion
- Iterator rowPointers =
- repeaterContext.iteratePointers(this.rowPath);
+ Iterator rowPointers = repeaterContext.iteratePointers(this.rowPath);
while (rowPointers.hasNext()) {
Pointer jxp = (Pointer) rowPointers.next();
- JXPathContext rowContext =
- repeaterContext.getRelativeContext(jxp);
+ JXPathContext rowContext = repeaterContext.getRelativeContext(jxp);
//TODO future might need data-conversion here
- String matchId =
- (String) rowContext.getValue(this.uniqueRowPath);
+ String matchId = (String) rowContext.getValue(this.uniqueRowPath);
// check if matchPath was in list of updates, if not --> bind for delete
if (!updatedRowIds.contains(matchId)) {
@@ -226,31 +209,24 @@
//register the factory!
this.insertRowBinding.saveFormToModel(repeater, repeaterContext);
while (rowIterator.hasNext()) {
- Repeater.RepeaterRow thisRow =
- (Repeater.RepeaterRow) rowIterator.next();
+ Repeater.RepeaterRow thisRow = (Repeater.RepeaterRow) rowIterator.next();
// --> create the path to let the context be created
- Pointer newRowContextPointer =
- repeaterContext.createPath(
- this.rowPath + "[" + indexCount + "]");
- JXPathContext newRowContext =
- repeaterContext.getRelativeContext(newRowContextPointer);
- getLogger().debug(
- "inserted row at " + newRowContextPointer.asPath());
+ Pointer newRowContextPointer = repeaterContext.createPath(this.rowPath + "[" + indexCount + "]");
+ JXPathContext newRowContext = repeaterContext.getRelativeContext(newRowContextPointer);
+ if (getLogger().isDebugEnabled())
+ getLogger().debug("inserted row at " + newRowContextPointer.asPath());
// + rebind to children for update
this.rowBinding.saveFormToModel(thisRow, newRowContext);
getLogger().debug("bound new row");
indexCount++;
}
- getLogger().debug("done saving rows " + toString());
+ if (getLogger().isDebugEnabled())
+ getLogger().debug("done saving rows " + toString());
}
public String toString() {
- return "RepeaterJXPathBinding [widget="
- + this.repeaterId
- + ", xpath="
- + this.repeaterPath
- + "]";
+ return "RepeaterJXPathBinding [widget=" + this.repeaterId + ", xpath=" + this.repeaterPath + "]";
}
public void enableLogging(Logger logger) {
1.2 +4 -3 cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/RepeaterJXPathBindingBuilder.java
Index: RepeaterJXPathBindingBuilder.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/RepeaterJXPathBindingBuilder.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- RepeaterJXPathBindingBuilder.java 22 Jul 2003 11:52:30 -0000 1.1
+++ RepeaterJXPathBindingBuilder.java 24 Jul 2003 12:39:17 -0000 1.2
@@ -94,7 +94,7 @@
*/
public JXPathBindingBase buildBinding(
Element bindingElm,
- JXPathBindingManager.Assistant assistant) {
+ JXPathBindingManager.Assistant assistant) throws BindingException {
try {
String repeaterId = DomHelper.getAttribute(bindingElm, "id");
@@ -142,9 +142,10 @@
deleteBindings);
return repeaterBinding;
+ } catch (BindingException e) {
+ throw e;
} catch (Exception e) {
- getLogger().warn("Error building a repeater field binding.", e);
- return null;
+ throw new BindingException("Error building repeater binding defined at " + DomHelper.getLocation(bindingElm), e);
}
}
}
1.2 +3 -15 cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/SetAttributeJXPathBinding.java
Index: SetAttributeJXPathBinding.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/SetAttributeJXPathBinding.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SetAttributeJXPathBinding.java 22 Jul 2003 11:52:30 -0000 1.1
+++ SetAttributeJXPathBinding.java 24 Jul 2003 12:39:17 -0000 1.2
@@ -68,9 +68,6 @@
/**
* Constructs SetAttributeJXPathBinding
- *
- * @param attName
- * @param attValue
*/
public SetAttributeJXPathBinding(String attName, String attValue) {
this.name = attName;
@@ -86,24 +83,15 @@
/**
* Sets the attribute value on the passed JXPathContext
- *
- * @param frmModel
- * @param jxpc
*/
public void saveFormToModel(Widget frmModel, JXPathContext jxpc) {
jxpc.setValue("@" + this.name, this.value);
- getLogger().debug("done saving " + toString());
+ if (getLogger().isDebugEnabled())
+ getLogger().debug("done saving " + toString());
}
- /**
- * @see java.lang.Object#toString()
- */
public String toString() {
- return "SetAttributeJXPathBinding [attName="
- + this.name
- + ", attValue="
- + this.value
- + "]";
+ return "SetAttributeJXPathBinding [attName=" + this.name + ", attValue=" + this.value + "]";
}
}
1.2 +4 -7 cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/SetAttributeJXPathBindingBuilder.java
Index: SetAttributeJXPathBindingBuilder.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/SetAttributeJXPathBindingBuilder.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SetAttributeJXPathBindingBuilder.java 22 Jul 2003 11:52:30 -0000 1.1
+++ SetAttributeJXPathBindingBuilder.java 24 Jul 2003 12:39:17 -0000 1.2
@@ -70,14 +70,10 @@
/**
* Creates an instance of {@link SetAttributeJXPathBinding} according to
* the attributes of the provided bindingElm.
- *
- * @param bindingElm
- * @param assistant
- * @return
*/
public JXPathBindingBase buildBinding(
Element bindingElm,
- JXPathBindingManager.Assistant assistant) {
+ JXPathBindingManager.Assistant assistant) throws BindingException {
try {
String attName = DomHelper.getAttribute(bindingElm, "name");
@@ -87,9 +83,10 @@
new SetAttributeJXPathBinding(attName, attValue);
return attBinding;
+ } catch (BindingException e) {
+ throw e;
} catch (Exception e) {
- getLogger().warn("Error building a field binding.", e);
- return null;
+ throw new BindingException("Error building binding defined at " + DomHelper.getLocation(bindingElm), e);
}
}