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 SimpleRepeaterJXPathBindingBuilder 36 extends JXPathBindingBuilderBase { 37 38 public JXPathBindingBase buildBinding(Element bindingElem, 39 JXPathBindingManager.Assistant assistant) throws BindingException { 40 try { 41 CommonAttributes commonAtts = 42 JXPathBindingBuilderBase.getCommonAttributes(bindingElem); 43 44 String repeaterId = DomHelper.getAttribute(bindingElem, "id", null); 45 String parentPath = DomHelper.getAttribute( 46 bindingElem, "parent-path", null); 47 String rowPath = DomHelper.getAttribute(bindingElem, "row-path", null); 48 boolean clearOnLoad = DomHelper.getAttributeAsBoolean( 49 bindingElem, "clear-before-load", true); 50 boolean deleteIfEmpty = DomHelper.getAttributeAsBoolean( 51 bindingElem, "delete-parent-if-empty", false); 52 53 JXPathBindingBase[] childBindings = null; 54 55 SimpleRepeaterJXPathBinding otherBinding = (SimpleRepeaterJXPathBinding)assistant.getContext().getSuperBinding(); 57 if(otherBinding!=null) { 58 childBindings = otherBinding.getChildBindings(); 59 commonAtts = JXPathBindingBuilderBase.mergeCommonAttributes(otherBinding.getCommonAtts(),commonAtts); 60 61 if(parentPath==null) 62 parentPath = otherBinding.getRepeaterPath(); 63 if(repeaterId==null) 64 repeaterId = otherBinding.getId(); 65 if(rowPath==null) 66 rowPath = otherBinding.getRowPath(); 67 if(!bindingElem.hasAttribute("clear-before-load")) 68 clearOnLoad = otherBinding.getClearOnLoad(); 69 if(!bindingElem.hasAttribute("delete-parent-if-empty")) 70 deleteIfEmpty = otherBinding.getDeleteIfEmpty(); 71 } 72 73 childBindings = assistant.makeChildBindings(bindingElem, childBindings); 74 75 return new SimpleRepeaterJXPathBinding(commonAtts, repeaterId, 76 parentPath, rowPath, clearOnLoad, deleteIfEmpty, 77 new ComposedJXPathBindingBase( 78 JXPathBindingBuilderBase.CommonAttributes.DEFAULT, 79 childBindings)); 80 } catch (BindingException e) { 81 throw e; 82 } catch (Exception e) { 83 throw new BindingException( 84 "Error building repeater binding defined at " + 85 DomHelper.getLocation(bindingElem), e); 86 } 87 } 88 } 89 | Popular Tags |