1 16 package org.apache.cocoon.forms.binding; 17 18 import org.apache.cocoon.forms.util.DomHelper; 19 import org.w3c.dom.Element ; 20 21 35 public class TempRepeaterJXPathBindingBuilder 36 extends JXPathBindingBuilderBase { 37 38 public JXPathBindingBase buildBinding(Element bindingElem, 39 JXPathBindingManager.Assistant assistant) throws BindingException { 40 try { 41 CommonAttributes commonAtts = JXPathBindingBuilderBase.getCommonAttributes(bindingElem); 42 43 String repeaterId = DomHelper.getAttribute(bindingElem, "id", null); 44 String parentPath = DomHelper.getAttribute(bindingElem, 45 "parent-path", null); 46 String rowPath = DomHelper.getAttribute(bindingElem, "row-path", null); 47 String rowPathInsert = DomHelper.getAttribute(bindingElem, 48 "row-path-insert", rowPath); 49 boolean virtualRows = DomHelper.getAttributeAsBoolean( 50 bindingElem, "virtual-rows", false); 51 boolean clearOnLoad = DomHelper.getAttributeAsBoolean( 52 bindingElem, "clear-before-load", true); 53 boolean deleteIfEmpty = DomHelper.getAttributeAsBoolean( 54 bindingElem, "delete-parent-if-empty", false); 55 56 JXPathBindingBase[] insertBindings = null; 57 JXPathBindingBase[] childBindings = null; 58 59 TempRepeaterJXPathBinding otherBinding = (TempRepeaterJXPathBinding)assistant.getContext().getSuperBinding(); 61 if(otherBinding!=null) { 62 childBindings = otherBinding.getChildBindings(); 63 insertBindings = otherBinding.getInsertChildBindings(); 64 commonAtts = JXPathBindingBuilderBase.mergeCommonAttributes(otherBinding.getCommonAtts(),commonAtts); 65 66 if(parentPath==null) 67 parentPath = otherBinding.getRepeaterPath(); 68 if(repeaterId==null) 69 repeaterId = otherBinding.getId(); 70 if(rowPath==null) 71 rowPath = otherBinding.getRowPath(); 72 if(rowPathInsert==null) 73 rowPathInsert = otherBinding.getRowPathInsert(); 74 if(!bindingElem.hasAttribute("virtual-rows")) 75 clearOnLoad = otherBinding.getVirtualRows(); 76 if(!bindingElem.hasAttribute("clear-before-load")) 77 clearOnLoad = otherBinding.getClearOnLoad(); 78 if(!bindingElem.hasAttribute("delete-parent-if-empty")) 79 deleteIfEmpty = otherBinding.getDeleteIfEmpty(); 80 } 81 82 Element childWrapElement = DomHelper.getChildElement( 83 bindingElem, BindingManager.NAMESPACE, "on-bind"); 84 childBindings = assistant.makeChildBindings(childWrapElement,childBindings); 85 86 Element insertWrapElement = DomHelper.getChildElement(bindingElem, 87 BindingManager.NAMESPACE, "on-insert-row"); 88 89 if (insertWrapElement != null) { 90 insertBindings = 91 assistant.makeChildBindings(insertWrapElement,insertBindings); 92 } 93 return new TempRepeaterJXPathBinding(commonAtts, repeaterId, 94 parentPath, rowPath, rowPathInsert, virtualRows, 95 clearOnLoad, deleteIfEmpty, 96 new ComposedJXPathBindingBase( 97 JXPathBindingBuilderBase.CommonAttributes.DEFAULT, 98 childBindings), 99 new ComposedJXPathBindingBase( 100 JXPathBindingBuilderBase.CommonAttributes.DEFAULT, 101 insertBindings)); 102 } catch (BindingException e) { 103 throw e; 104 } catch (Exception e) { 105 throw new BindingException( 106 "Error building temp-repeater binding defined at " + 107 DomHelper.getLocation(bindingElem), e); 108 } 109 } 110 } 111 | Popular Tags |