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