1 16 package org.apache.cocoon.forms.binding; 17 18 import org.apache.cocoon.forms.formmodel.AggregateField; 19 import org.apache.cocoon.forms.formmodel.Widget; 20 import org.apache.commons.jxpath.JXPathContext; 21 22 33 public class AggregateJXPathBinding extends ComposedJXPathBindingBase { 34 35 private final String xpath; 36 37 private final String widgetId; 38 39 45 public AggregateJXPathBinding( 46 JXPathBindingBuilderBase.CommonAttributes commonAtts, 47 String widgetId, String xpath, JXPathBindingBase[] childBindings) { 48 super(commonAtts, childBindings); 49 this.widgetId = widgetId; 50 this.xpath = xpath; 51 } 52 53 public String getXPath() { return xpath; } 54 public String getId() { return widgetId; } 55 56 61 public void doLoad(Widget frmModel, 62 JXPathContext jxpc) throws BindingException { 63 AggregateField aggregate = 64 (AggregateField)selectWidget(frmModel, this.widgetId); 65 JXPathContext subContext = 66 jxpc.getRelativeContext(jxpc.getPointer(this.xpath)); 67 super.doLoad(aggregate, subContext); 68 aggregate.combineFields(); 69 if (getLogger().isDebugEnabled()) { 70 getLogger().debug("Done loading " + toString()); 71 } 72 } 73 74 79 public void doSave(Widget frmModel, 80 JXPathContext jxpc) throws BindingException { 81 AggregateField aggregate = 82 (AggregateField)selectWidget(frmModel, this.widgetId); 83 JXPathContext subContext = 84 jxpc.getRelativeContext(jxpc.getPointer(this.xpath)); 85 super.doSave(aggregate, subContext); 86 if (getLogger().isDebugEnabled()) { 87 getLogger().debug("Done saving " + toString()); 88 } 89 } 90 91 public String toString() { 92 return "AggregateJXPathBinding [widget=" + this.widgetId + 93 ", xpath=" + this.xpath + "]"; 94 } 95 } 96 | Popular Tags |