1 29 30 package com.caucho.jsp.java; 31 32 import com.caucho.jsp.JspParseException; 33 import com.caucho.vfs.WriteStream; 34 import com.caucho.xml.QName; 35 36 import java.io.IOException ; 37 38 public class JstlFmtParam extends JstlNode { 39 private static final QName VALUE = new QName("value"); 40 41 private String _value; 42 private JspAttribute _valueAttr; 43 46 public void addAttribute(QName name, String value) 47 throws JspParseException 48 { 49 if (VALUE.equals(name)) 50 _value = value; 51 else 52 throw error(L.l("`{0}' is an unknown attribute for <{1}>.", 53 name.getName(), getTagName())); 54 } 55 56 59 public boolean hasScripting() 60 { 61 return (super.hasScripting() || 62 hasScripting(_value) || hasScripting(_valueAttr)); 63 } 64 65 70 public void printXml(WriteStream os) 71 throws IOException 72 { 73 os.print("<fmt:param>"); 74 75 printXmlText(os, _value); 76 77 printXmlChildren(os); 78 79 os.print("</fmt:param>"); 80 } 81 82 85 public void generate(JspJavaWriter out) 86 throws Exception 87 { 88 throw error(L.l("fmt:param can't be called directly.")); 89 } 90 91 94 public void generateSet(JspJavaWriter out, String lhs) 95 throws Exception 96 { 97 if (_value != null) { 98 if (! getRuntimeAttribute(_value).equals(_value)) { 99 101 out.println(lhs + " = String.valueOf(" + getRuntimeAttribute(_value) + ");"); 102 } 103 else { 104 int paramIndex = _gen.addExpr(_value); 105 106 out.println(lhs + " = _caucho_expr_" + paramIndex + ".evalObject(_jsp_env);"); 107 } 108 } 109 else { 110 out.println("out = pageContext.pushBody();"); 111 112 generateChildren(out); 113 114 out.println(lhs + " = ((com.caucho.jsp.BodyContentImpl) out).getTrimString();"); 115 116 out.println("out = pageContext.popBody();"); 117 } 118 } 119 } 120 | Popular Tags |