1 16 package org.apache.cocoon.forms.binding; 17 18 import org.apache.cocoon.forms.formmodel.Widget; 19 import org.apache.commons.jxpath.JXPathContext; 20 21 32 public class NewJXPathBinding extends ComposedJXPathBindingBase { 33 34 private final String widgetId; 35 36 private Binding classBinding; 37 38 44 public NewJXPathBinding(JXPathBindingBuilderBase.CommonAttributes commonAtts, 45 String widgetId, JXPathBindingBase[] childBindings) { 46 super(commonAtts, childBindings); 47 this.widgetId = widgetId; 48 this.classBinding = null; 49 } 50 51 public String getId() { return widgetId; } 52 53 56 private void resolve() throws BindingException { 57 classBinding = getClass(widgetId); 58 if (classBinding == null) { 59 throw new BindingException("Class \"" + widgetId + "\" does not exist"); 60 } 61 } 62 63 68 public void doLoad(Widget frmModel, JXPathContext jxpc) throws BindingException { 69 if (classBinding == null) 70 resolve(); 71 Binding[] subBindings = ((ComposedJXPathBindingBase)classBinding).getChildBindings(); 72 if (subBindings != null) { 73 int size = subBindings.length; 74 for (int i = 0; i < size; i++) { 75 subBindings[i].loadFormFromModel(frmModel, jxpc); 76 } 77 } 78 } 79 80 85 public void doSave(Widget frmModel, JXPathContext jxpc) throws BindingException { 86 if (classBinding == null) 87 resolve(); 88 Binding[] subBindings = ((ComposedJXPathBindingBase)classBinding).getChildBindings(); 89 if (subBindings != null) { 90 int size = subBindings.length; 91 for (int i = 0; i < size; i++) { 92 subBindings[i].saveFormToModel(frmModel, jxpc); 93 } 94 } 95 } 96 97 public String toString() { 98 return "NewJXPathBinding [widget=" + this.widgetId + "]"; 99 } 100 } 101 | Popular Tags |