1 16 package org.apache.cocoon.forms.binding; 17 18 import java.util.Collections ; 19 import java.util.HashMap ; 20 21 import org.apache.avalon.framework.logger.Logger; 22 import org.apache.cocoon.forms.formmodel.Widget; 23 import org.apache.commons.jxpath.JXPathContext; 24 25 32 public class ComposedJXPathBindingBase extends JXPathBindingBase { 33 private final JXPathBindingBase[] subBindings; 34 35 public String getXPath() { return null; } 36 37 42 public ComposedJXPathBindingBase(JXPathBindingBuilderBase.CommonAttributes commonAtts, JXPathBindingBase[] childBindings) { 43 super(commonAtts); 44 this.subBindings = childBindings; 45 if (this.subBindings != null) { 46 for (int i = 0; i < this.subBindings.length; i++) { 47 this.subBindings[i].setParent(this); 48 } 49 } 50 } 51 52 56 public void enableLogging(Logger logger) { 57 super.enableLogging(logger); 58 if (this.subBindings != null) { 59 for (int i = 0; i < this.subBindings.length; i++) { 60 this.subBindings[i].enableLogging(logger); 61 } 62 } 63 } 64 65 69 public Binding getClass(String id) { 70 if (classes == null) { 71 classes = new HashMap (); 72 if (this.subBindings != null) { 73 for (int i = 0; i < this.subBindings.length; i++) { 74 Binding binding = this.subBindings[i]; 75 if (binding instanceof ClassJXPathBinding) { 76 String bindingId = binding.getId(); 77 if (bindingId != null) 78 classes.put(bindingId, binding); 79 } 80 } 81 82 if (classes.size() == 0) { 84 classes = Collections.EMPTY_MAP; 85 } 86 } 87 } 88 return super.getClass(id); 89 } 90 91 94 public JXPathBindingBase[] getChildBindings() { 95 return subBindings; 96 } 97 98 102 public void doLoad(Widget frmModel, JXPathContext jxpc) throws BindingException { 103 if (this.subBindings != null) { 104 int size = this.subBindings.length; 105 for (int i = 0; i < size; i++) { 106 this.subBindings[i].loadFormFromModel(frmModel, jxpc); 107 } 108 } 109 } 110 111 115 public void doSave(Widget frmModel, JXPathContext jxpc) throws BindingException { 116 if (this.subBindings != null) { 117 int size = this.subBindings.length; 118 for (int i = 0; i < size; i++) { 119 this.subBindings[i].saveFormToModel(frmModel, jxpc); 120 } 121 } 122 } 123 } 124 | Popular Tags |