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 import org.w3c.dom.Document ; 21 import org.w3c.dom.DocumentFragment ; 22 import org.w3c.dom.Node ; 23 24 36 public class InsertNodeJXPathBinding extends JXPathBindingBase { 37 38 private final DocumentFragment template; 39 40 43 public InsertNodeJXPathBinding(JXPathBindingBuilderBase.CommonAttributes commonAtts, DocumentFragment domTemplate) { 44 super(commonAtts); 45 this.template = domTemplate; 46 } 47 48 public DocumentFragment getTemplate() { return template; } 49 50 53 public void doLoad(Widget frmModel, JXPathContext jxpc) { 54 } 56 57 63 public void doSave(Widget frmModel, JXPathContext jxpc) { 64 65 Node parentNode = (Node )jxpc.getContextBean(); 66 Document targetDoc = parentNode.getOwnerDocument(); 67 Node toInsert = targetDoc.importNode(this.template, true); 68 parentNode.appendChild(toInsert); 69 70 if (getLogger().isDebugEnabled()) 71 getLogger().debug("InsertNode executed."); 72 73 } 91 92 public String toString() { 93 return "InsertNodeJXPathBinding [for nested template]"; 94 } 95 } 96 | Popular Tags |