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/runtime JspFragmentHelper.java
Date Mon, 05 Aug 2002 21:05:24 GMT
luehe       2002/08/05 14:05:24

  Modified:    jasper2/src/share/org/apache/jasper/compiler Generator.java
               jasper2/src/share/org/apache/jasper/runtime
                        JspFragmentHelper.java
  Log:
  - Whenever a JSP fragment invokes a tag handler, it must use its
  associated tag handler instance (that is, the instance of the tag
  handler of the nearest enclosing tag invocation) when calling
  setParent().
  
  - Integrated javax.servlet.jsp.tagext.TagAdapter
  
  Revision  Changes    Path
  1.62      +54 -13    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.61
  retrieving revision 1.62
  diff -u -r1.61 -r1.62
  --- Generator.java	3 Aug 2002 23:29:21 -0000	1.61
  +++ Generator.java	5 Aug 2002 21:05:24 -0000	1.62
  @@ -1553,7 +1553,7 @@
   		out.print(tagMethod);
   		out.print("(");
   		if (parent != null) {
  -		    out.print("javax.servlet.jsp.tagext.Tag ");
  +		    out.print("javax.servlet.jsp.tagext.JspTag ");
   		    out.print(parent);
   		    out.print(", ");
   		}
  @@ -2337,16 +2337,48 @@
   				     boolean simpleTag)
   	            throws JasperException {
   
  +	    // Set context
   	    out.printin(tagHandlerVar);
   	    if (simpleTag) {
   		out.println(".setJspContext(pageContext);");
   	    } else {
   		out.println(".setPageContext(pageContext);");
   	    }
  -	    out.printin(tagHandlerVar);
  -	    out.print(".setParent(");
  -	    out.print(parent);
  -	    out.println(");");
  +
  +	    // Set parent
  +	    if (!simpleTag) {
  +		if (parent != null) {
  +		    out.printin("if (!(");
  +		    out.print(parent);
  +		    out.println(" instanceof javax.servlet.jsp.tagext.Tag))");
  +		    out.pushIndent();
  +		    out.printin(tagHandlerVar);
  +		    out.print(".setParent(");
  +		    out.print("new javax.servlet.jsp.tagext.TagAdapter(");
  +		    out.print(parent);
  +		    out.print(", ");
  +		    out.print("null"); // XXX
  +		    out.println("));");
  +		    out.popIndent();
  +		    out.printil("else");
  +		    out.pushIndent();
  +		    out.printin(tagHandlerVar);
  +		    out.print(".setParent((javax.servlet.jsp.tagext.Tag) ");
  +		    out.print(parent);
  +		    out.println(");");
  +		    out.popIndent();
  +		} else {
  +		    out.printin(tagHandlerVar);
  +		    out.print(".setParent(");
  +		    out.print(parent);
  +		    out.println(");");
  +		}
  +	    } else {
  +		out.printin(tagHandlerVar);
  +		out.print(".setParent(");
  +		out.print(parent);
  +		out.println(");");
  +	    }
   
   	    Node.JspAttribute[] attrs = n.getJspAttributes();
   	    for (int i=0; i<attrs.length; i++) {
  @@ -2533,11 +2565,14 @@
               // body.  The implementation of this fragment can come from
               // the org.apache.jasper.runtime package as a support class.
               FragmentHelperClass.Fragment fragment = 
  -                fragmentHelperClass.openFragment( n );
  +                fragmentHelperClass.openFragment(n, tagHandlerVar);
               ServletWriter outSave = out;
   	    out = fragment.getMethodsBuffer().getOut();
  +	    String tmpParent = parent;
  +	    parent = tagHandlerVar;
               visitBody( n );
               out = outSave;
  +	    parent = tmpParent;
   	    fragmentHelperClass.closeFragment( fragment );
               // XXX - Need to change pageContext to jspContext if
               // we're not in a place where pageContext is defined (e.g.
  @@ -3151,16 +3186,19 @@
                   "org.apache.jasper.runtime.JspFragmentHelper" );
               out.printil( "{" );
               out.pushIndent();
  +	    out.printil("private javax.servlet.jsp.tagext.JspTag parentTag;");
  +	    out.println();
               out.printil( "public " + className + 
                   "( int discriminator, JspContext jspContext, " +
  -                "Object parentTag ) {" );
  +                "javax.servlet.jsp.tagext.JspTag parentTag ) {" );
               out.pushIndent();
               out.printil( "super( discriminator, jspContext, parentTag );" );
  +            out.printil( "this.parentTag = parentTag;" );
               out.popIndent();
               out.printil( "}" );
           }
           
  -	public Fragment openFragment( Node parent ) 
  +	public Fragment openFragment(Node parent, String tagHandlerVar) 
               throws JasperException 
           {
               Fragment result = new Fragment( fragments.size() );
  @@ -3176,8 +3214,8 @@
               // meaning only the fragment is skipped.  The JSR-152
               // expert group is currently discussing what to do in this case.
               // See comment in closeFragment()
  -            out.printil( "public boolean invoke" + result.getId() + "( " +
  -                "java.io.Writer out, java.util.Map params ) " );
  +	    out.printil( "public boolean invoke" + result.getId() + "( " +
  +			 "java.io.Writer out, java.util.Map params ) " );
               out.pushIndent();
               // Note: Throwable required because methods like _jspx_meth_*
               // throw Throwable.
  @@ -3186,6 +3224,9 @@
               out.printil( "{" );
               out.pushIndent();
               generateLocalVariables( out, parent );
  +	    out.printin("javax.servlet.jsp.tagext.JspTag ");
  +	    out.print(tagHandlerVar);
  +	    out.println(" = parentTag;");
               
               return result;
           }
  
  
  
  1.2       +7 -6      jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/JspFragmentHelper.java
  
  Index: JspFragmentHelper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/JspFragmentHelper.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JspFragmentHelper.java	16 Jul 2002 19:30:52 -0000	1.1
  +++ JspFragmentHelper.java	5 Aug 2002 21:05:24 -0000	1.2
  @@ -64,6 +64,7 @@
   import javax.servlet.jsp.JspContext;
   import javax.servlet.jsp.PageContext;
   
  +import javax.servlet.jsp.tagext.JspTag;
   import javax.servlet.jsp.tagext.JspFragment;
   
   import java.util.HashMap;
  @@ -88,11 +89,11 @@
       protected int discriminator;
       protected JspContext jspContext;
       protected PageContext pageContext;
  -    protected Object parentTag;
  +    protected JspTag parentTag;
       protected Map originalPageScope;
   
       public JspFragmentHelper( int discriminator, JspContext jspContext, 
  -        Object parentTag ) 
  +        JspTag parentTag ) 
       {
           this.discriminator = discriminator;
           this.jspContext = jspContext;
  @@ -108,7 +109,7 @@
           return this.jspContext;
       }
       
  -    public Object getParentTag() {
  +    public JspTag getParentTag() {
           return this.parentTag;
       }
       
  
  
  

--
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