1 16 package org.apache.cocoon.woody.binding; 17 18 import org.apache.cocoon.woody.formmodel.Widget; 19 import org.apache.commons.jxpath.JXPathContext; 20 21 33 public class NewJXPathBinding extends ComposedJXPathBindingBase { 34 35 private final String widgetId; 36 37 private Binding classBinding; 38 39 45 public NewJXPathBinding(JXPathBindingBuilderBase.CommonAttributes commonAtts, String widgetId, JXPathBindingBase[] childBindings) { 46 super(commonAtts, childBindings); 47 this.widgetId = widgetId; 48 this.classBinding = null; 49 } 50 51 private void resolve() { 52 classBinding = getClass(widgetId); 53 } 54 55 60 public void doLoad(Widget frmModel, JXPathContext jxpc) throws BindingException { 61 if (classBinding == null) 62 resolve(); 63 if (classBinding instanceof ClassJXPathBinding) { 64 Binding[] subBindings = ((ComposedJXPathBindingBase)classBinding).getChildBindings(); 65 if (subBindings != null) { 66 int size = subBindings.length; 67 for (int i = 0; i < size; i++) { 68 subBindings[i].loadFormFromModel(frmModel, jxpc); 69 } 70 } 71 } else { 72 classBinding.loadFormFromModel(frmModel, jxpc); 73 } 74 } 75 76 81 public void doSave(Widget frmModel, JXPathContext jxpc) throws BindingException { 82 if (classBinding == null) 83 resolve(); 84 if (classBinding instanceof ClassJXPathBinding) { 85 Binding[] subBindings = ((ComposedJXPathBindingBase)classBinding).getChildBindings(); 86 if (subBindings != null) { 87 int size = subBindings.length; 88 for (int i = 0; i < size; i++) { 89 subBindings[i].saveFormToModel(frmModel, jxpc); 90 } 91 } 92 } else { 93 classBinding.saveFormToModel(frmModel, jxpc); 94 } 95 } 96 97 public String toString() { 98 return "NewJXPathBinding [widget=" + this.widgetId + "]"; 99 } 100 } 101 | Popular Tags |