1 16 package org.apache.cocoon.woody.binding; 17 18 import org.apache.cocoon.woody.formmodel.Union; 19 import org.apache.cocoon.woody.formmodel.Widget; 20 import org.apache.commons.jxpath.JXPathContext; 21 22 34 public class CaseJXPathBinding extends ComposedJXPathBindingBase { 35 36 private final String xpath; 37 38 private final String widgetId; 39 40 47 public CaseJXPathBinding(JXPathBindingBuilderBase.CommonAttributes commonAtts, String widgetId, String xpath, JXPathBindingBase[] childBindings) { 48 super(commonAtts, childBindings); 49 this.widgetId = widgetId; 50 this.xpath = xpath; 51 } 52 53 58 public void doLoad(Widget frmModel, JXPathContext jxpc) throws BindingException { 59 Union unionWidget = (Union)frmModel; 60 if (widgetId.equals(unionWidget.getValue())) { 61 Binding[] subBindings = getChildBindings(); 63 if (subBindings != null) { 64 int size = subBindings.length; 65 for (int i = 0; i < size; i++) { 66 subBindings[i].loadFormFromModel(unionWidget, jxpc); 67 } 68 } 69 if (getLogger().isDebugEnabled()) { 70 getLogger().debug("done loading " + toString()); 71 } 72 } 73 } 74 75 80 public void doSave(Widget frmModel, JXPathContext jxpc) throws BindingException { 81 Union unionWidget = (Union)frmModel; 82 if (widgetId.equals(unionWidget.getValue())) { 83 Binding[] subBindings = getChildBindings(); 85 if (subBindings != null) { 86 int size = subBindings.length; 87 for (int i = 0; i < size; i++) { 88 subBindings[i].saveFormToModel(unionWidget, jxpc); 89 } 90 } 91 if (getLogger().isDebugEnabled()) { 92 getLogger().debug("done saving " + toString()); 93 } 94 } 95 } 96 97 public String toString() { 98 return "CaseJXPathBinding [widget=" + this.widgetId + ", xpath=" + this.xpath + "]"; 99 } 100 } 101 | Popular Tags |