luehe       2003/03/28 15:15:46

  Modified:    jasper2/src/share/org/apache/jasper/compiler Compiler.java
                        Generator.java TagFileProcessor.java
  Log:
  Implemented latest JSP 2.0 spec changes regarding dynamic attributes
  in Tag Files:
  
  - Dynamic attributes are exposed in a Map named for the value of the
    "dynamic-attributes" tag-directive attribute
  
  - The Map contains each dynamic attribute name as the key and the
    dynamic attribute value as the corresponding value.  Only dynamic
    attributes with no uri are to be present in the Map; all other
    dynamic attributes are ignored.
  
  Revision  Changes    Path
  1.62      +1 -0      
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Compiler.java
  
  Index: Compiler.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Compiler.java,v
  retrieving revision 1.61
  retrieving revision 1.62
  diff -u -r1.61 -r1.62
  --- Compiler.java     28 Mar 2003 02:13:02 -0000      1.61
  +++ Compiler.java     28 Mar 2003 23:15:45 -0000      1.62
  @@ -196,6 +196,7 @@
           throws Exception
       {
           long t1=System.currentTimeMillis();
  +
        // Setup page info area
        pageInfo = new PageInfo(new BeanRepository(ctxt.getClassLoader(),
                                                   errDispatcher));
  
  
  
  1.177     +18 -22    
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.176
  retrieving revision 1.177
  diff -u -r1.176 -r1.177
  --- Generator.java    24 Mar 2003 17:35:26 -0000      1.176
  +++ Generator.java    28 Mar 2003 23:15:45 -0000      1.177
  @@ -2880,7 +2880,7 @@
               gen.compileTagHandlerPoolList(page);
           }
        if (gen.ctxt.isTagFile()) {
  -         TagInfo tagInfo = gen.ctxt.getTagInfo();
  +         JasperTagInfo tagInfo = (JasperTagInfo) gen.ctxt.getTagInfo();
            gen.generateTagHandlerPreamble(tagInfo, page);
   
            if (gen.ctxt.isPrototypeMode()) {
  @@ -2913,7 +2913,8 @@
       /*
        * Generates tag handler preamble.
        */
  -    private void generateTagHandlerPreamble(TagInfo tagInfo, Node.Nodes tag )
  +    private void generateTagHandlerPreamble(JasperTagInfo tagInfo,
  +                                         Node.Nodes tag )
           throws JasperException 
       {
   
  @@ -3063,7 +3064,7 @@
                throws JasperException {
   
        if (tagInfo.hasDynamicAttributes()) {
  -         out.printil("private java.util.HashMap dynamicAttrs = new 
java.util.HashMap();");
  +         out.printil("private java.util.HashMap _jspx_dynamic_attrs = new 
java.util.HashMap();");
        }
   
        // Declare attributes
  @@ -3218,15 +3219,13 @@
       public void generateSetDynamicAttribute() {
           out.printil("public void setDynamicAttribute(String uri, String localName, 
Object value) throws javax.servlet.jsp.JspException {");
        out.pushIndent();
  -     out.printil("if (uri != null)");
  -     out.pushIndent();
  -     // XXX Specification still needs to clarify what the variable name
  -     // looks like. Assume <uri>_<localName> for now.
  -     out.printil("dynamicAttrs.put(uri + \"_\" + localName, value);");
  -     out.popIndent();
  -     out.printil("else");
  +     /* 
  +      * According to the spec, only dynamic attributes with no uri are to
  +      * be present in the Map; all other dynamic attributes are ignored.
  +      */
  +     out.printil("if (uri == null)");
        out.pushIndent();
  -     out.printil("dynamicAttrs.put(localName, value);");
  +     out.printil("_jspx_dynamic_attrs.put(localName, value);");
        out.popIndent();
        out.popIndent();
        out.printil("}");
  @@ -3237,7 +3236,7 @@
        * Also, if the tag accepts dynamic attributes, a page-scoped variable
        * is made available for each dynamic attribute that was passed in.
        */
  -    private void generatePageScopedVariables(TagInfo tagInfo) {
  +    private void generatePageScopedVariables(JasperTagInfo tagInfo) {
   
        // "normal" attributes
        TagAttributeInfo[] attrInfos = tagInfo.getAttributes();
  @@ -3253,14 +3252,11 @@
            out.popIndent();
        }
   
  -     // dynamic attributes
  +     // Expose the Map containing dynamic attributes as a page-scoped var
        if (tagInfo.hasDynamicAttributes()) {
  -         out.printil("for (java.util.Iterator i = 
dynamicAttrs.entrySet().iterator(); i.hasNext(); ) {");
  -         out.pushIndent();
  -         out.printil("java.util.Map.Entry e = (java.util.Map.Entry) i.next();");
  -         out.printil("pageContext.setAttribute((String) e.getKey(), 
e.getValue());");
  -         out.popIndent();
  -         out.printil("}");
  +         out.printin("pageContext.setAttribute(\"");
  +         out.print(tagInfo.getDynamicAttributesMapName());
  +         out.print("\", _jspx_dynamic_attrs);");
        }
       }
   
  
  
  
  1.47      +5 -6      
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TagFileProcessor.java
  
  Index: TagFileProcessor.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TagFileProcessor.java,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- TagFileProcessor.java     28 Mar 2003 02:13:02 -0000      1.46
  +++ TagFileProcessor.java     28 Mar 2003 23:15:45 -0000      1.47
  @@ -134,7 +134,7 @@
           private String displayName = null;
           private String smallIcon = null;
           private String largeIcon = null;
  -        private boolean dynamicAttrs = false;
  +        private String dynamicAttrs;
           
           private Vector attributeVector;
           private Vector variableVector;
  @@ -164,8 +164,7 @@
                   err.jspError(n, "jsp.error.tagdirective.badbodycontent",
                                bodycontent);
               }
  -            dynamicAttrs = JspUtil.booleanValue(
  -                         n.getAttributeValue("dynamic-attributes"));
  +            dynamicAttrs = n.getAttributeValue("dynamic-attributes");
               smallIcon = n.getAttributeValue("small-icon");
               largeIcon = n.getAttributeValue("large-icon");
               description = n.getAttributeValue("description");
  @@ -303,7 +302,7 @@
                   = new TagAttributeInfo[attributeVector.size()];
               attributeVector.copyInto(tagAttributeInfo);
   
  -            return new TagInfo(name,
  +            return new JasperTagInfo(name,
                               tagClassName,
                               bodycontent,
                               description,
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to