1 28 29 package com.caucho.jstl.el; 30 31 import com.caucho.jsp.PageContextImpl; 32 import com.caucho.log.Log; 33 import com.caucho.xpath.Env; 34 import com.caucho.xpath.XPath; 35 import com.caucho.xpath.XPathException; 36 37 import org.w3c.dom.Node ; 38 39 import javax.servlet.jsp.JspException ; 40 import javax.servlet.jsp.tagext.TagSupport ; 41 import java.util.logging.Level ; 42 import java.util.logging.Logger ; 43 44 public class XmlSetTag extends TagSupport { 45 private static final Logger log = Log.open(XmlSetTag.class); 46 private com.caucho.xpath.Expr _select; 47 48 private String _var; 49 private String _scope; 50 51 54 public void setSelect(com.caucho.xpath.Expr select) 55 { 56 _select = select; 57 } 58 59 62 public void setVar(String var) 63 { 64 _var = var; 65 } 66 67 70 public void setScope(String scope) 71 { 72 _scope = scope; 73 } 74 75 78 public int doStartTag() 79 throws JspException 80 { 81 try { 82 PageContextImpl pageContext = (PageContextImpl) this.pageContext; 83 84 Object value = evalObject(pageContext, _select); 85 86 CoreSetTag.setValue(pageContext, _var, _scope, value); 87 } catch (Exception e) { 88 log.log(Level.FINE, e.toString(), e); 89 } 90 91 return SKIP_BODY; 92 } 93 94 97 public static Object evalObject(PageContextImpl pageContext, 98 com.caucho.xpath.Expr select) 99 throws XPathException 100 { 101 Env env = XPath.createEnv(); 102 env.setVarEnv(pageContext.getVarEnv()); 103 104 Node node = pageContext.getNodeEnv(); 105 106 Object value = select.evalObject(node, env); 107 108 env.free(); 109 110 return value; 111 } 112 } 113 | Popular Tags |