1 16 package org.apache.cocoon.forms.binding; 17 18 import org.apache.cocoon.forms.binding.JXPathBindingBuilderBase.CommonAttributes; 19 import org.apache.cocoon.forms.formmodel.Widget; 20 import org.apache.commons.jxpath.JXPathContext; 21 22 25 public class CustomJXPathBinding extends JXPathBindingBase { 26 27 30 private final String widgetId; 31 32 35 private final String xpath; 36 37 40 private final AbstractCustomBinding wrappedBinding; 41 42 50 public CustomJXPathBinding(CommonAttributes commonAtts, String widgetId, 51 String xpath, AbstractCustomBinding wrappedBinding) { 52 super(commonAtts); 53 this.widgetId = widgetId; 54 this.xpath = xpath; 55 this.wrappedBinding = wrappedBinding; 56 } 57 58 public String getXPath() { return xpath; } 59 public String getId() { return widgetId; } 60 public AbstractCustomBinding getWrappedBinding() { return wrappedBinding; } 61 62 70 public void doLoad(Widget frmModel, JXPathContext jxpc) throws BindingException { 71 Widget selectedWidget = selectWidget(frmModel, this.widgetId); 72 JXPathContext context = jxpc.getRelativeContext(jxpc.getPointer(this.xpath)); 73 74 this.wrappedBinding.loadFormFromModel(selectedWidget, context); 75 } 76 77 85 public void doSave(Widget frmModel, JXPathContext jxpc) throws BindingException { 86 Widget selectedWidget = selectWidget(frmModel, this.widgetId); 87 JXPathContext context = jxpc.getRelativeContext(jxpc.getPointer(this.xpath)); 88 89 this.wrappedBinding.saveFormToModel(selectedWidget, context); 90 } 91 92 93 } 94 | Popular Tags |