pierred     00/10/28 20:23:51

  Modified:    jasper/src/share/org/apache/jasper/compiler
                        TagLibraryInfoImpl.java
               jasper/src/share/org/apache/jasper/resources
                        messages.properties
  Log:
  Support for new JSP1.2 feature:
  "Added elements to the TLD to avoid having to write TagExtraInfo
  classes in the most common cases."
  
  TagLibraryInfoImpl
  - Support the new sub-elements of <tag>
    display-name, small-icon, large-icon, variable
  
  messages.properties
  - new error messages
  
  Revision  Changes    Path
  1.6       +92 -8     
jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/TagLibraryInfoImpl.java
  
  Index: TagLibraryInfoImpl.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/TagLibraryInfoImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TagLibraryInfoImpl.java   2000/10/27 21:23:34     1.5
  +++ TagLibraryInfoImpl.java   2000/10/29 03:23:50     1.6
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/TagLibraryInfoImpl.java,v
 1.5 2000/10/27 21:23:34 pierred Exp $
  - * $Revision: 1.5 $
  - * $Date: 2000/10/27 21:23:34 $
  + * $Header: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/TagLibraryInfoImpl.java,v
 1.6 2000/10/29 03:23:50 pierred Exp $
  + * $Revision: 1.6 $
  + * $Date: 2000/10/29 03:23:50 $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -81,6 +81,8 @@
   import javax.servlet.jsp.tagext.TagExtraInfo;
   import javax.servlet.jsp.tagext.TagLibraryValidator;
   import javax.servlet.jsp.tagext.PageData;
  +import javax.servlet.jsp.tagext.VariableInfo;
  +import javax.servlet.jsp.tagext.TagVariableInfo;
   
   import org.w3c.dom.*;
   import org.xml.sax.*;
  @@ -429,11 +431,17 @@
       }
   
       private TagInfo createTagInfo(Element elem) throws JasperException {
  -        String name = null, tagclass = null, teiclass = null;
  +        String name = null;
  +     String tagclass = null;
  +     String teiclass = null;
           String bodycontent = "JSP"; // Default body content is JSP
        String info = null;
  +     String displayName = null;
  +     String smallIcon = null;
  +     String largeIcon = null;
           
           Vector attributeVector = new Vector();
  +        Vector variableVector = new Vector();
           NodeList list = elem.getChildNodes();
           for(int i = 0; i < list.getLength(); i++) {
               Node tmp  =  list.item(i);
  @@ -460,20 +468,46 @@
                   Text t = (Text) e.getFirstChild();
                   if (t != null)
                       info = t.getData();
  -            } else if (tname.equals("attribute"))
  +            } else if (tname.equals("attribute")) {
                   attributeVector.addElement(createAttribute(e));
  -            else 
  +
  +         // JSP 1.2
  +
  +         } else if (tname.equals("display-name")) {
  +                Text t = (Text) e.getFirstChild();
  +                if (t != null)
  +                    displayName = t.getData();
  +         } else if (tname.equals("small-icon")) {
  +                Text t = (Text) e.getFirstChild();
  +                if (t != null)
  +                    smallIcon = t.getData();
  +         } else if (tname.equals("large-icon")) {
  +                Text t = (Text) e.getFirstChild();
  +                if (t != null)
  +                    largeIcon = t.getData();
  +         } else if (tname.equals("variable")) {
  +             if (teiclass != null) {
  +                 throw new JasperException(
  +                     Constants.getString("tld.error.variableNotAllowed"));
  +             }
  +             variableVector.addElement(createVariable(e));
  +         } else {
                   Constants.message("jsp.warning.unknown.element.in.tag", 
                                     new Object[] {
                                         e.getTagName()
                                     },
                                     Logger.WARNING
                                     );
  -        }
  +         }
  +     }
        TagAttributeInfo[] tagAttributeInfo 
               = new TagAttributeInfo[attributeVector.size()];
        attributeVector.copyInto (tagAttributeInfo);
   
  +     TagVariableInfo[] tagVariableInfos
  +            = new TagVariableInfo[variableVector.size()];
  +     variableVector.copyInto(tagVariableInfos);
  +
           TagExtraInfo tei = null;
   
           if (teiclass != null && !teiclass.equals(""))
  @@ -506,7 +540,11 @@
           TagInfo taginfo = new TagInfo(name, tagclass, bodycontent,
                                         info, this, 
                                         tei,
  -                                      tagAttributeInfo);
  +                                      tagAttributeInfo,
  +                                   displayName,
  +                                   smallIcon,
  +                                   largeIcon,
  +                                   tagVariableInfos);
           return taginfo;
       }
   
  @@ -554,6 +592,52 @@
           
        //     return new TagAttributeInfo(name, required, rtexprvalue, type);
           return new TagAttributeInfo(name, required, type, rtexprvalue);
  +    }
  +
  +    TagVariableInfo createVariable(Element elem) {
  +        String nameGiven = null;
  +        String nameFromAttribute = null;
  +     String className = null;
  +     boolean declare = true;
  +     int scope = VariableInfo.NESTED;
  +        
  +        NodeList list = elem.getChildNodes();
  +        for(int i=0; i<list.getLength(); i++) {
  +            Node tmp  = list.item(i);
  +         if (!(tmp instanceof Element)) continue;
  +         Element e = (Element) tmp;
  +            String tname = e.getTagName();
  +            if (tname.equals("name-given"))  {
  +                Text t = (Text) e.getFirstChild();
  +                if (t != null)
  +                    nameGiven = t.getData();
  +            } else if (tname.equals("name-from-attribute"))  {
  +                Text t = (Text) e.getFirstChild();
  +                if (t != null)
  +                    nameFromAttribute = t.getData();
  +            } else if (tname.equals("variable-class"))  {
  +                Text t = (Text) e.getFirstChild();
  +                if (t != null)
  +                    className = t.getData();
  +            } else if (tname.equals("declare"))  {
  +                Text t = (Text) e.getFirstChild();
  +                if (t != null) {
  +                    declare = Boolean.valueOf(t.getData()).booleanValue();
  +                 if (t.getData().equalsIgnoreCase("yes"))
  +                     declare = true;
  +             }
  +            } else if (tname.equals("scope")) {
  +                Text t = (Text) e.getFirstChild();
  +                if (t != null) {
  +                    scope = Integer.valueOf(t.getData()).intValue();
  +             }
  +            } else 
  +                Constants.message("jsp.warning.unknown.element.in.variable",
  +                                  new Object[] {e.getTagName()},
  +                                  Logger.WARNING);
  +        }
  +        return new TagVariableInfo(nameGiven, nameFromAttribute,
  +                                className, declare, scope);
       }
   
       static void copy(InputStream in, String fileName) 
  
  
  
  1.7       +3 -1      
jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/resources/messages.properties
  
  Index: messages.properties
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/resources/messages.properties,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- messages.properties       2000/10/28 03:20:23     1.6
  +++ messages.properties       2000/10/29 03:23:51     1.7
  @@ -1,4 +1,4 @@
  -# $Id: messages.properties,v 1.6 2000/10/28 03:20:23 pierred Exp $
  +# $Id: messages.properties,v 1.7 2000/10/29 03:23:51 pierred Exp $
   #
   # Default localized string information
   # Localized this the Default Locale as is en_US
  @@ -226,3 +226,5 @@
   jsp.error.include.flush.invalid.value=Invalid value for the flush attribute: {0}
   jsp.error.page.invalid.pageencoding=Page directive: invalid value for pageEncoding
   jsp.error.unsupported.encoding=Unsupported encoding: {0}
  +jsp.warning.unknown.element.in.variable=Warning: Unknown element {0} in variable
  +tld.error.variableNotAllowed=It is an error for a tag that has one or more variable 
subelements to have a TagExtraInfo class that returns a non-null object.
  
  
  

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

Reply via email to