tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu...@apache.org
Subject cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler Generator.java Validator.java
Date Mon, 19 Aug 2002 18:44:42 GMT
luehe       2002/08/19 11:44:42

  Modified:    jasper2/src/share/org/apache/jasper/compiler Generator.java
                        Validator.java
  Log:
  Added support for 'var' attribute to <jsp:invoke> and <jsp:doBody>
  
  Revision  Changes    Path
  1.68      +26 -14    jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java
  
  Index: Generator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java,v
  retrieving revision 1.67
  retrieving revision 1.68
  diff -u -r1.67 -r1.68
  --- Generator.java	19 Aug 2002 16:54:16 -0000	1.67
  +++ Generator.java	19 Aug 2002 18:44:42 -0000	1.68
  @@ -1741,8 +1741,9 @@
   	    }
   	    
   	    // Invoke fragment with parameter map
  -	    String varReader = n.getAttributeValue("varReader");
  -	    if (varReader != null) {
  +	    String varReaderAttr = n.getAttributeValue("varReader");
  +	    String varAttr = n.getAttributeValue("var");
  +	    if (varReaderAttr != null || varAttr != null) {
   		out.printil("sout = new java.io.StringWriter();");
   		out.print(toGetterMethod(n.getAttributeValue("fragment")));
   		out.println(".invoke(sout, params);");
  @@ -1752,11 +1753,16 @@
   	    }
   
   	    // Store varReader in appropriate scope
  -	    if (varReader != null) {
  +	    if (varReaderAttr != null || varAttr != null) {
   		String scopeName = n.getAttributeValue("scope");
   		out.printin("pageContext.setAttribute(");
  -		out.print(quote(varReader));
  -		out.print(", new java.io.StringReader(sout.toString())");
  +		if (varReaderAttr != null) {
  +		    out.print(quote(varReaderAttr));
  +		    out.print(", new java.io.StringReader(sout.toString())");
  +		} else {
  +		    out.print(quote(varAttr));
  +		    out.print(", sout.toString()");
  +		}		    
   		if (scopeName != null) {
   		    out.print(", ");
   		    out.print(getScopeConstant(scopeName));
  @@ -1816,8 +1822,9 @@
   	    }
   
   	    // Invoke body with parameter map
  -	    String varReader = n.getAttributeValue("varReader");
  -	    if (varReader != null) {
  +	    String varReaderAttr = n.getAttributeValue("varReader");
  +	    String varAttr = n.getAttributeValue("var");
  +	    if (varReaderAttr != null || varAttr != null) {
   		out.printil("sout = new java.io.StringWriter();");
   		out.printil("getJspBody().invoke(sout, params);");
   	    } else {
  @@ -1825,11 +1832,16 @@
   	    }
   
   	    // Store varReader in appropriate scope
  -	    if (varReader != null) {
  +	    if (varReaderAttr != null || varAttr != null) {
   		String scopeName = n.getAttributeValue("scope");
   		out.printin("pageContext.setAttribute(");
  -		out.print(quote(varReader));
  -		out.print(", new java.io.StringReader(sout.toString())");
  +		if (varReaderAttr != null) {
  +		    out.print(quote(varReaderAttr));
  +		    out.print(", new java.io.StringReader(sout.toString())");
  +		} else {
  +		    out.print(quote(varAttr));
  +		    out.print(", sout.toString()");
  +		}
   		if (scopeName != null) {
   		    out.print(", ");
   		    out.print(getScopeConstant(scopeName));
  @@ -2822,7 +2834,7 @@
   	out.printil("java.util.Map params = null;");
   
   	// Declare writer used for storing result of fragment/body invocation
  -	// if 'varReader' attribute is specified
  +	// if 'varReader' or 'var' attribute is specified
   	out.printil("java.io.Writer sout = null;");
   
   	out.printil("javax.servlet.jsp.JspWriter out = pageContext.getOut();");
  
  
  
  1.22      +32 -3     jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Validator.java
  
  Index: Validator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Validator.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- Validator.java	19 Aug 2002 16:54:16 -0000	1.21
  +++ Validator.java	19 Aug 2002 18:44:42 -0000	1.22
  @@ -359,6 +359,17 @@
           private static final JspUtil.ValidAttribute[] bodyAttrs = {
               new JspUtil.ValidAttribute("value") };
   
  +        private static final JspUtil.ValidAttribute[] invokeAttrs = {
  +            new JspUtil.ValidAttribute("fragment", true),
  +	    new JspUtil.ValidAttribute("var"),
  +	    new JspUtil.ValidAttribute("varReader"),
  +	    new JspUtil.ValidAttribute("scope") };
  +
  +        private static final JspUtil.ValidAttribute[] doBodyAttrs = {
  +            new JspUtil.ValidAttribute("var"),
  +	    new JspUtil.ValidAttribute("varReader"),
  +	    new JspUtil.ValidAttribute("scope") };
  +
   	/*
   	 * Constructor
   	 */
  @@ -770,6 +781,24 @@
   
               return result;
           }
  +
  +	public void visit(Node.InvokeAction n) throws JasperException {
  +            JspUtil.checkAttributes("Invoke", n, invokeAttrs, err);
  +	    if (n.getAttributeValue("var") != null
  +		    && n.getAttributeValue("varReader") != null) {
  +		err.jspError(n, "jsp.error.invoke.varAndVarReader");
  +	    }
  +            visitBody(n);
  +	}
  +
  +	public void visit(Node.DoBodyAction n) throws JasperException {
  +            JspUtil.checkAttributes("DoBody", n, doBodyAttrs, err);
  +	    if (n.getAttributeValue("var") != null
  +		    && n.getAttributeValue("varReader") != null) {
  +		err.jspError(n, "jsp.error.doBody.varAndVarReader");
  +	    }
  +            visitBody(n);
  +	}
       }
   
       /**
  
  
  

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message