antonio 2004/02/29 04:36:19
Modified: src/blocks/woody/java/org/apache/cocoon/woody/binding
SimpleRepeaterJXPathBindingBuilder.java
RepeaterJXPathBindingBuilder.java
RepeaterJXPathBinding.java
SetAttributeJXPathBindingBuilder.java
TempRepeaterJXPathBindingBuilder.java
Log:
Formatting code
Revision Changes Path
1.8 +20 -12
cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/SimpleRepeaterJXPathBindingBuilder.java
Index: SimpleRepeaterJXPathBindingBuilder.java
===================================================================
RCS file:
/home/cvs//cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/SimpleRepeaterJXPathBindingBuilder.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- SimpleRepeaterJXPathBindingBuilder.java 3 Feb 2004 12:26:21 -0000
1.7
+++ SimpleRepeaterJXPathBindingBuilder.java 29 Feb 2004 12:36:19 -0000
1.8
@@ -70,27 +70,35 @@
public class SimpleRepeaterJXPathBindingBuilder
extends JXPathBindingBuilderBase {
- public JXPathBindingBase buildBinding(
- Element bindingElem,
+ public JXPathBindingBase buildBinding(Element bindingElem,
JXPathBindingManager.Assistant assistant) throws BindingException {
-
try {
- CommonAttributes commonAtts =
JXPathBindingBuilderBase.getCommonAttributes(bindingElem);
+ CommonAttributes commonAtts =
+ JXPathBindingBuilderBase.getCommonAttributes(bindingElem);
String repeaterId = DomHelper.getAttribute(bindingElem, "id");
- String parentPath = DomHelper.getAttribute(bindingElem,
"parent-path");
+ String parentPath = DomHelper.getAttribute(
+ bindingElem, "parent-path");
String rowPath = DomHelper.getAttribute(bindingElem, "row-path");
- boolean clearOnLoad =
DomHelper.getAttributeAsBoolean(bindingElem, "clear-before-load", true);
- boolean deleteIfEmpty =
DomHelper.getAttributeAsBoolean(bindingElem, "delete-parent-if-empty", false);
+ boolean clearOnLoad = DomHelper.getAttributeAsBoolean(
+ bindingElem, "clear-before-load", true);
+ boolean deleteIfEmpty = DomHelper.getAttributeAsBoolean(
+ bindingElem, "delete-parent-if-empty", false);
- JXPathBindingBase[] childBindings =
assistant.makeChildBindings(bindingElem);
+ JXPathBindingBase[] childBindings =
+ assistant.makeChildBindings(bindingElem);
- return new SimpleRepeaterJXPathBinding( commonAtts, repeaterId,
parentPath, rowPath, clearOnLoad, deleteIfEmpty,
- new
ComposedJXPathBindingBase(JXPathBindingBuilderBase.CommonAttributes.DEFAULT,
childBindings));
+ return new SimpleRepeaterJXPathBinding(commonAtts, repeaterId,
+ parentPath, rowPath, clearOnLoad, deleteIfEmpty,
+ new ComposedJXPathBindingBase(
+
JXPathBindingBuilderBase.CommonAttributes.DEFAULT,
+ childBindings));
} catch (BindingException e) {
throw e;
} catch (Exception e) {
- throw new BindingException("Error building repeater binding
defined at " + DomHelper.getLocation(bindingElem), e);
+ throw new BindingException(
+ "Error building repeater binding defined at " +
+ DomHelper.getLocation(bindingElem), e);
}
}
}
1.12 +41 -45
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.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- RepeaterJXPathBindingBuilder.java 3 Feb 2004 12:26:21 -0000 1.11
+++ RepeaterJXPathBindingBuilder.java 29 Feb 2004 12:36:19 -0000 1.12
@@ -88,8 +88,7 @@
*
* @version CVS $Id$
*/
-public class RepeaterJXPathBindingBuilder
- extends JXPathBindingBuilderBase {
+public class RepeaterJXPathBindingBuilder extends JXPathBindingBuilderBase {
/**
* Creates an instance of [EMAIL PROTECTED] RepeaterJXPathBinding}
according to the
@@ -99,82 +98,79 @@
* @param assistant
* @return JXPathBindingBase
*/
- public JXPathBindingBase buildBinding(
- Element bindingElm,
- JXPathBindingManager.Assistant assistant) throws BindingException {
+ public JXPathBindingBase buildBinding(Element bindingElm,
+ JXPathBindingManager.Assistant assistant) throws
BindingException {
try {
- CommonAttributes commonAtts =
JXPathBindingBuilderBase.getCommonAttributes(bindingElm);
+ CommonAttributes commonAtts =
+ JXPathBindingBuilderBase.getCommonAttributes(bindingElm);
String repeaterId = DomHelper.getAttribute(bindingElm, "id");
String parentPath =
DomHelper.getAttribute(bindingElm, "parent-path");
String rowPath = DomHelper.getAttribute(bindingElm, "row-path");
- String rowPathForInsert = DomHelper.getAttribute(bindingElm,
"row-path-insert", rowPath);
+ String rowPathForInsert =
+ DomHelper.getAttribute(bindingElm, "row-path-insert",
rowPath);
String uniqueRowId =
DomHelper.getAttribute(bindingElm, "unique-row-id");
String uniqueRowIdPath =
DomHelper.getAttribute(bindingElm, "unique-path");
-
Convertor convertor = null;
Locale convertorLocale = Locale.US;
- Element convertorEl = DomHelper.getChildElement(bindingElm,
Constants.WD_NS, "convertor");
+ Element convertorEl =
+ DomHelper.getChildElement(bindingElm,
+ Constants.WD_NS, "convertor");
if (convertorEl != null) {
- String datatype = DomHelper.getAttribute(convertorEl,
"datatype");
+ String datatype =
+ DomHelper.getAttribute(convertorEl, "datatype");
String localeStr = convertorEl.getAttribute("datatype");
- if (!localeStr.equals(""))
+ if (!localeStr.equals("")) {
convertorLocale = I18nUtils.parseLocale(localeStr);
- convertor =
assistant.getDatatypeManager().createConvertor(datatype, convertorEl);
+ }
+ convertor =
+ assistant.getDatatypeManager().createConvertor(datatype,
+ convertorEl);
}
- Element childWrapElement =
- DomHelper.getChildElement(
- bindingElm,
- BindingManager.NAMESPACE,
- "on-bind");
-
+ Element childWrapElement = DomHelper.getChildElement(bindingElm,
+ BindingManager.NAMESPACE, "on-bind");
if (childWrapElement == null) {
- throw new BindingException("RepeaterBinding misses
'<on-bind>' child definition. " +
-
DomHelper.getLocation(bindingElm));
+ throw new BindingException(
+ "RepeaterBinding misses '<on-bind>' child definition.
" +
+ DomHelper.getLocation(bindingElm));
}
- JXPathBindingBase[] childBindings =
assistant.makeChildBindings(childWrapElement);
-
- Element deleteWrapElement =
- DomHelper.getChildElement(
- bindingElm,
- BindingManager.NAMESPACE,
- "on-delete-row");
+ JXPathBindingBase[] childBindings =
+ assistant.makeChildBindings(childWrapElement);
+ Element deleteWrapElement = DomHelper.getChildElement(bindingElm,
+ BindingManager.NAMESPACE, "on-delete-row");
JXPathBindingBase[] deleteBindings = null;
- if(deleteWrapElement != null) {
- deleteBindings =
assistant.makeChildBindings(deleteWrapElement);
+ if (deleteWrapElement != null) {
+ deleteBindings =
+ assistant.makeChildBindings(deleteWrapElement);
}
- Element insertWrapElement =
- DomHelper.getChildElement(
- bindingElm,
- BindingManager.NAMESPACE,
- "on-insert-row");
+ Element insertWrapElement = DomHelper.getChildElement(bindingElm,
+ BindingManager.NAMESPACE, "on-insert-row");
JXPathBindingBase insertBinding = null;
if (insertWrapElement != null) {
- insertBinding =
assistant.makeChildBindings(insertWrapElement)[0];
-
+ insertBinding =
+ assistant.makeChildBindings(insertWrapElement)[0];
}
RepeaterJXPathBinding repeaterBinding =
- new RepeaterJXPathBinding(
- commonAtts,
- repeaterId, parentPath, rowPath, rowPathForInsert,
- uniqueRowId, uniqueRowIdPath,
- convertor, convertorLocale,
- childBindings, insertBinding, deleteBindings);
-
+ new RepeaterJXPathBinding(commonAtts, repeaterId, parentPath,
+ rowPath, rowPathForInsert, uniqueRowId,
+ uniqueRowIdPath, convertor, convertorLocale,
+ childBindings, insertBinding, deleteBindings);
return repeaterBinding;
} catch (BindingException e) {
throw e;
} catch (Exception e) {
- throw new BindingException("Error building repeater binding
defined at " + DomHelper.getLocation(bindingElm), e);
+ throw new BindingException(
+ "Error building repeater binding defined at " +
+ DomHelper.getLocation(bindingElm), e);
}
}
}
1.20 +91 -74
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.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- RepeaterJXPathBinding.java 3 Feb 2004 12:26:21 -0000 1.19
+++ RepeaterJXPathBinding.java 29 Feb 2004 12:36:19 -0000 1.20
@@ -89,25 +89,28 @@
/**
* Constructs RepeaterJXPathBinding
*/
- public RepeaterJXPathBinding(JXPathBindingBuilderBase.CommonAttributes
commonAtts,
- String repeaterId, String repeaterPath,
- String rowPath, String rowPathForInsert,
- String uniqueRowId, String uniqueRowPath,
- JXPathBindingBase[] childBindings,
- JXPathBindingBase insertBinding,
JXPathBindingBase[] deleteBindings) {
- this(commonAtts, repeaterId, repeaterPath, rowPath,
rowPathForInsert, uniqueRowId, uniqueRowPath, null, null, childBindings,
insertBinding, deleteBindings);
+ public RepeaterJXPathBinding(
+ JXPathBindingBuilderBase.CommonAttributes commonAtts,
+ String repeaterId, String repeaterPath, String rowPath,
+ String rowPathForInsert, String uniqueRowId,
+ String uniqueRowPath, JXPathBindingBase[] childBindings,
+ JXPathBindingBase insertBinding,
+ JXPathBindingBase[] deleteBindings) {
+ this(commonAtts, repeaterId, repeaterPath, rowPath, rowPathForInsert,
+ uniqueRowId, uniqueRowPath, null, null, childBindings,
+ insertBinding, deleteBindings);
}
/**
* Constructs RepeaterJXPathBinding
*/
- public RepeaterJXPathBinding(JXPathBindingBuilderBase.CommonAttributes
commonAtts,
- String repeaterId, String repeaterPath,
- String rowPath, String rowPathForInsert,
- String uniqueRowId, String uniqueRowPath,
- Convertor convertor, Locale convertorLocale,
- JXPathBindingBase[] childBindings,
- JXPathBindingBase insertBinding,
JXPathBindingBase[] deleteBindings) {
+ public RepeaterJXPathBinding(
+ JXPathBindingBuilderBase.CommonAttributes commonAtts,
+ String repeaterId, String repeaterPath, String rowPath,
+ String rowPathForInsert, String uniqueRowId,
+ String uniqueRowPath, Convertor convertor, Locale
convertorLocale,
+ JXPathBindingBase[] childBindings, JXPathBindingBase
insertBinding,
+ JXPathBindingBase[] deleteBindings) {
super(commonAtts);
this.repeaterId = repeaterId;
this.repeaterPath = repeaterPath;
@@ -115,38 +118,43 @@
this.rowPathForInsert = rowPathForInsert;
this.uniqueRowId = uniqueRowId;
this.uniqueRowIdPath = uniqueRowPath;
- this.uniqueFieldBinding =
- new
ValueJXPathBinding(JXPathBindingBuilderBase.CommonAttributes.DEFAULT,
uniqueRowId, uniqueRowPath, null, convertor, convertorLocale);
+ this.uniqueFieldBinding = new ValueJXPathBinding(
+ JXPathBindingBuilderBase.CommonAttributes.DEFAULT,
uniqueRowId,
+ uniqueRowPath, null, convertor, convertorLocale);
this.uniqueRowIdConvertor = convertor;
this.uniqueRowIdConvertorLocale = convertorLocale;
- this.rowBinding = new
ComposedJXPathBindingBase(JXPathBindingBuilderBase.CommonAttributes.DEFAULT,
childBindings);
+ this.rowBinding = new ComposedJXPathBindingBase(
+ JXPathBindingBuilderBase.CommonAttributes.DEFAULT,
+ childBindings);
this.rowBinding.setParent(this);
this.insertRowBinding = insertBinding;
if (this.insertRowBinding != null) {
this.insertRowBinding.setParent(this);
}
- this.deleteRowBinding = new
ComposedJXPathBindingBase(JXPathBindingBuilderBase.CommonAttributes.DEFAULT,
deleteBindings);
+ this.deleteRowBinding = new ComposedJXPathBindingBase(
+ JXPathBindingBuilderBase.CommonAttributes.DEFAULT,
+ deleteBindings);
if (this.deleteRowBinding != null) {
this.deleteRowBinding.setParent(this);
}
}
-
/**
* 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.
*/
- public void doLoad(Widget frmModel, JXPathContext jxpc) throws
BindingException {
+ public void doLoad(Widget frmModel, JXPathContext jxpc)
+ throws BindingException {
// Find the repeater
Repeater repeater = (Repeater) frmModel.getWidget(this.repeaterId);
repeater.removeRows();
int initialSize = repeater.getSize();
// build a jxpath iterator for pointers
- JXPathContext repeaterContext =
jxpc.getRelativeContext(jxpc.getPointer(this.repeaterPath));
+ JXPathContext repeaterContext =
+ jxpc.getRelativeContext(jxpc.getPointer(this.repeaterPath));
Iterator rowPointers = repeaterContext.iteratePointers(this.rowPath);
-
//iterate through it
while (rowPointers.hasNext()) {
// create a new row, take that as the frmModelSubContext
@@ -156,30 +164,26 @@
} else {
thisRow = repeater.addRow();
}
-
// make a jxpath ObjectModelSubcontext on the iterated element
Pointer jxp = (Pointer) rowPointers.next();
JXPathContext rowContext =
repeaterContext.getRelativeContext(jxp);
-
// hand it over to children
this.uniqueFieldBinding.loadFormFromModel(thisRow, rowContext);
this.rowBinding.loadFormFromModel(thisRow, rowContext);
}
-
if (getLogger().isDebugEnabled())
getLogger().debug("done loading rows " + toString());
}
-
/**
* Uses the mapped unique-id of each row to detect if rows have been
* updated, inserted or removed. Depending on what happened the
appropriate
* child-bindings are alowed to visit the narrowed contexts.
*/
- public void doSave(Widget frmModel, JXPathContext jxpc) throws
BindingException {
+ public void doSave(Widget frmModel, JXPathContext jxpc)
+ throws BindingException {
// Find the repeater
Repeater repeater = (Repeater) frmModel.getWidget(this.repeaterId);
-
// and his context
JXPathContext repeaterContext =
jxpc.getRelativeContext(jxpc.getPointer(this.repeaterPath));
@@ -206,16 +210,7 @@
Pointer jxp = (Pointer) rowPointers.next();
JXPathContext rowContext =
repeaterContext.getRelativeContext(jxp);
-
- Object matchId =
rowContext.getValue(this.uniqueRowIdPath);
- if (matchId != null && this.uniqueRowIdConvertor !=
null) {
- if (matchId instanceof String) {
- matchId =
this.uniqueRowIdConvertor.convertFromString((String)matchId,
this.uniqueRowIdConvertorLocale, null);
- } else {
- getLogger().warn("Convertor ignored on
backend-value which isn't of type String.");
- }
- }
-
+ Object matchId = getMatchId(rowContext);
if (rowIdValue.equals(matchId)) {
// match! --> bind to children
this.rowBinding.saveFormToModel(thisRow, rowContext);
@@ -236,41 +231,36 @@
rowsToInsert.add(thisRow);
}
}
-
//again iterate nodes for deletion
Iterator rowPointers = repeaterContext.iteratePointers(this.rowPath);
List rowsToDelete = new ArrayList();
while (rowPointers.hasNext()) {
Pointer jxp = (Pointer) rowPointers.next();
- JXPathContext rowContext =
repeaterContext.getRelativeContext((Pointer)jxp.clone());
-
- Object matchId = rowContext.getValue(this.uniqueRowIdPath);
- if (matchId != null && this.uniqueRowIdConvertor != null) {
- if (matchId instanceof String) {
- matchId =
this.uniqueRowIdConvertor.convertFromString((String)matchId,
this.uniqueRowIdConvertorLocale, null);
- } else {
- getLogger().warn("Convertor ignored on backend-value
which isn't of type String.");
- }
- }
-
+ JXPathContext rowContext =
+ repeaterContext.getRelativeContext((Pointer)jxp.clone());
+ Object matchId = getMatchId(rowContext);
// check if matchPath was in list of updates, if not --> bind
for delete
if (!updatedRowIds.contains(matchId)) {
rowsToDelete.add(rowContext);
}
}
-
if (rowsToDelete.size() > 0) {
- if (this.deleteRowBinding == null) {
- getLogger().warn("RepeaterBinding has detected rows to
delete, " +
- "but misses the <on-delete-row> binding to do it.");
- }
- else {
- // run backwards through the list, so that we don't get into
trouble by shifting indexes
- for (int i = rowsToDelete.size() - 1; i >= 0; i--)
- this.deleteRowBinding.saveFormToModel(frmModel,
rowsToDelete.get(i));
+ if (this.deleteRowBinding != null) {
+ // run backwards through the list, so that we don't get into
+ // trouble by shifting indexes
+ for (int i = rowsToDelete.size() - 1; i >= 0; i--) {
+ this.deleteRowBinding.saveFormToModel(frmModel,
+ rowsToDelete.get(i));
+ }
+ } else {
+ if (getLogger().isWarnEnabled()) {
+ getLogger().warn(
+ "RepeaterBinding has detected rows to delete, " +
+ "but misses the <on-delete-row> binding to do
it."
+ );
+ }
}
}
-
// count how many we have now
int indexCount = 1;
rowPointers = repeaterContext.iteratePointers(this.rowPathForInsert);
@@ -278,40 +268,67 @@
rowPointers.next();
indexCount++;
}
-
// end with rows to insert (to make sure they don't get deleted!)
- if(rowsToInsert.size() > 0) {
+ if (rowsToInsert.size() > 0) {
if (this.insertRowBinding != null) {
Iterator rowIterator = rowsToInsert.iterator();
//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();
// Perform the insert row binding.
- this.insertRowBinding.saveFormToModel(repeater,
repeaterContext);
+ this.insertRowBinding.saveFormToModel(repeater,
+ repeaterContext);
// --> create the path to let the context be created
- Pointer newRowContextPointer =
repeaterContext.createPath(this.rowPathForInsert + "[" + indexCount + "]");
- JXPathContext newRowContext =
repeaterContext.getRelativeContext(newRowContextPointer);
+ Pointer newRowContextPointer =
repeaterContext.createPath(
+ this.rowPathForInsert + "[" + indexCount + "]");
+ JXPathContext newRowContext =
+ repeaterContext.getRelativeContext(
+ newRowContextPointer);
if (getLogger().isDebugEnabled())
- getLogger().debug("inserted row at " +
newRowContextPointer.asPath());
+ getLogger().debug("inserted row at " +
+ newRowContextPointer.asPath());
// + rebind to children for update
this.rowBinding.saveFormToModel(thisRow, newRowContext);
getLogger().debug("bound new row");
indexCount++;
}
} else {
- getLogger().warn("RepeaterBinding has detected rows to
insert, " +
- "but misses the <on-insert-row> binding to do it.");
+ if (getLogger().isWarnEnabled()) {
+ getLogger().warn(
+ "RepeaterBinding has detected rows to insert, " +
+ "but misses the <on-insert-row> binding to do
it."
+ );
+ }
}
}
-
-
- if (getLogger().isDebugEnabled())
+ if (getLogger().isDebugEnabled()) {
getLogger().debug("done saving rows " + toString());
+ }
+ }
+
+ private Object getMatchId(JXPathContext rowContext) {
+ Object matchId;
+ matchId = rowContext.getValue(this.uniqueRowIdPath);
+ if (matchId != null && this.uniqueRowIdConvertor != null) {
+ if (matchId instanceof String) {
+ matchId = this.uniqueRowIdConvertor.convertFromString(
+ (String)matchId,
+ this.uniqueRowIdConvertorLocale, null);
+ } else {
+ if (getLogger().isWarnEnabled()) {
+ getLogger().warn("Convertor ignored on backend-value " +
+ "which isn't of type String.");
+ }
+ }
+ }
+ return matchId;
}
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.7 +7 -6
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.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- SetAttributeJXPathBindingBuilder.java 3 Feb 2004 12:26:21 -0000
1.6
+++ SetAttributeJXPathBindingBuilder.java 29 Feb 2004 12:36:19 -0000
1.7
@@ -73,24 +73,25 @@
* Creates an instance of [EMAIL PROTECTED] SetAttributeJXPathBinding}
according to
* the attributes of the provided bindingElm.
*/
- public JXPathBindingBase buildBinding(
- Element bindingElm,
+ public JXPathBindingBase buildBinding(Element bindingElm,
JXPathBindingManager.Assistant assistant) throws BindingException {
try {
- CommonAttributes commonAtts =
JXPathBindingBuilderBase.getCommonAttributes(bindingElm);
+ CommonAttributes commonAtts =
+ JXPathBindingBuilderBase.getCommonAttributes(bindingElm);
String attName = DomHelper.getAttribute(bindingElm, "name");
String attValue = DomHelper.getAttribute(bindingElm, "value");
SetAttributeJXPathBinding attBinding =
new SetAttributeJXPathBinding(commonAtts, attName, attValue);
-
return attBinding;
} catch (BindingException e) {
throw e;
} catch (Exception e) {
- throw new BindingException("Error building binding defined at "
+ DomHelper.getLocation(bindingElm), e);
+ throw new BindingException(
+ "Error building set-attribute binding defined at " +
+ DomHelper.getLocation(bindingElm), e);
}
}
}
1.5 +35 -27
cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/TempRepeaterJXPathBindingBuilder.java
Index: TempRepeaterJXPathBindingBuilder.java
===================================================================
RCS file:
/home/cvs//cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/TempRepeaterJXPathBindingBuilder.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TempRepeaterJXPathBindingBuilder.java 3 Feb 2004 12:26:21 -0000
1.4
+++ TempRepeaterJXPathBindingBuilder.java 29 Feb 2004 12:36:19 -0000
1.5
@@ -71,43 +71,51 @@
public class TempRepeaterJXPathBindingBuilder
extends JXPathBindingBuilderBase {
- public JXPathBindingBase buildBinding(
- Element bindingElem,
+ public JXPathBindingBase buildBinding(Element bindingElem,
JXPathBindingManager.Assistant assistant) throws BindingException {
-
try {
CommonAttributes commonAtts =
JXPathBindingBuilderBase.getCommonAttributes(bindingElem);
String repeaterId = DomHelper.getAttribute(bindingElem, "id");
- String parentPath = DomHelper.getAttribute(bindingElem,
"parent-path");
+ String parentPath = DomHelper.getAttribute(bindingElem,
+ "parent-path");
String rowPath = DomHelper.getAttribute(bindingElem, "row-path");
- String rowPathInsert = DomHelper.getAttribute(bindingElem,
"row-path-insert", rowPath);
- boolean virtualRows =
DomHelper.getAttributeAsBoolean(bindingElem, "virtual-rows", false);
- boolean clearOnLoad =
DomHelper.getAttributeAsBoolean(bindingElem, "clear-before-load", true);
- boolean deleteIfEmpty =
DomHelper.getAttributeAsBoolean(bindingElem, "delete-parent-if-empty", false);
+ String rowPathInsert = DomHelper.getAttribute(bindingElem,
+ "row-path-insert", rowPath);
+ boolean virtualRows = DomHelper.getAttributeAsBoolean(
+ bindingElem, "virtual-rows", false);
+ boolean clearOnLoad = DomHelper.getAttributeAsBoolean(
+ bindingElem, "clear-before-load", true);
+ boolean deleteIfEmpty = DomHelper.getAttributeAsBoolean(
+ bindingElem, "delete-parent-if-empty", false);
- Element childWrapElement =
- DomHelper.getChildElement(bindingElem,
BindingManager.NAMESPACE, "on-bind");
- JXPathBindingBase[] childBindings =
assistant.makeChildBindings(childWrapElement);
+ Element childWrapElement = DomHelper.getChildElement(
+ bindingElem, BindingManager.NAMESPACE, "on-bind");
+ JXPathBindingBase[] childBindings =
+ assistant.makeChildBindings(childWrapElement);
- Element insertWrapElement =
- DomHelper.getChildElement(
- bindingElem,
- BindingManager.NAMESPACE,
- "on-insert-row");
+ Element insertWrapElement =
DomHelper.getChildElement(bindingElem,
+ BindingManager.NAMESPACE, "on-insert-row");
JXPathBindingBase[] insertBindings = null;
- if (insertWrapElement != null)
- insertBindings =
assistant.makeChildBindings(insertWrapElement);
-
- return new TempRepeaterJXPathBinding(
- commonAtts, repeaterId, parentPath, rowPath, rowPathInsert,
virtualRows, clearOnLoad, deleteIfEmpty,
- new
ComposedJXPathBindingBase(JXPathBindingBuilderBase.CommonAttributes.DEFAULT,
childBindings),
- new
ComposedJXPathBindingBase(JXPathBindingBuilderBase.CommonAttributes.DEFAULT,
insertBindings));
+ if (insertWrapElement != null) {
+ insertBindings =
+ assistant.makeChildBindings(insertWrapElement);
+ }
+ return new TempRepeaterJXPathBinding(commonAtts, repeaterId,
+ parentPath, rowPath, rowPathInsert, virtualRows,
+ clearOnLoad, deleteIfEmpty,
+ new ComposedJXPathBindingBase(
+
JXPathBindingBuilderBase.CommonAttributes.DEFAULT,
+ childBindings),
+ new ComposedJXPathBindingBase(
+
JXPathBindingBuilderBase.CommonAttributes.DEFAULT,
+ insertBindings));
} catch (BindingException e) {
throw e;
} catch (Exception e) {
- throw new BindingException("Error building temp-repeater binding
defined at " +
- DomHelper.getLocation(bindingElem), e);
+ throw new BindingException(
+ "Error building temp-repeater binding defined at " +
+ DomHelper.getLocation(bindingElem), e);
}
}
}