1 16 package org.apache.cocoon.woody.binding; 17 18 import org.apache.cocoon.woody.util.DomHelper; 19 import org.w3c.dom.Element ; 20 21 36 public class TempRepeaterJXPathBindingBuilder 37 extends JXPathBindingBuilderBase { 38 39 public JXPathBindingBase buildBinding(Element bindingElem, 40 JXPathBindingManager.Assistant assistant) throws BindingException { 41 try { 42 CommonAttributes commonAtts = JXPathBindingBuilderBase.getCommonAttributes(bindingElem); 43 44 String repeaterId = DomHelper.getAttribute(bindingElem, "id"); 45 String parentPath = DomHelper.getAttribute(bindingElem, 46 "parent-path"); 47 String rowPath = DomHelper.getAttribute(bindingElem, "row-path"); 48 String rowPathInsert = DomHelper.getAttribute(bindingElem, 49 "row-path-insert", rowPath); 50 boolean virtualRows = DomHelper.getAttributeAsBoolean( 51 bindingElem, "virtual-rows", false); 52 boolean clearOnLoad = DomHelper.getAttributeAsBoolean( 53 bindingElem, "clear-before-load", true); 54 boolean deleteIfEmpty = DomHelper.getAttributeAsBoolean( 55 bindingElem, "delete-parent-if-empty", false); 56 57 Element childWrapElement = DomHelper.getChildElement( 58 bindingElem, BindingManager.NAMESPACE, "on-bind"); 59 JXPathBindingBase[] childBindings = 60 assistant.makeChildBindings(childWrapElement); 61 62 Element insertWrapElement = DomHelper.getChildElement(bindingElem, 63 BindingManager.NAMESPACE, "on-insert-row"); 64 JXPathBindingBase[] insertBindings = null; 65 if (insertWrapElement != null) { 66 insertBindings = 67 assistant.makeChildBindings(insertWrapElement); 68 } 69 return new TempRepeaterJXPathBinding(commonAtts, repeaterId, 70 parentPath, rowPath, rowPathInsert, virtualRows, 71 clearOnLoad, deleteIfEmpty, 72 new ComposedJXPathBindingBase( 73 JXPathBindingBuilderBase.CommonAttributes.DEFAULT, 74 childBindings), 75 new ComposedJXPathBindingBase( 76 JXPathBindingBuilderBase.CommonAttributes.DEFAULT, 77 insertBindings)); 78 } catch (BindingException e) { 79 throw e; 80 } catch (Exception e) { 81 throw new BindingException( 82 "Error building temp-repeater binding defined at " + 83 DomHelper.getLocation(bindingElem), e); 84 } 85 } 86 } 87 | Popular Tags |