Package javax.servlet.jsp.tagext

Examples of javax.servlet.jsp.tagext.TagInfo


        }

        public void visit(Node.CustomTag n) throws JasperException {
            TagLibraryInfo tagLibInfo = (TagLibraryInfo)
                pageInfo.getTagLibraries().get(n.getPrefix());
            TagInfo tagInfo = tagLibInfo.getTag(n.getShortName());
            if (tagInfo == null) {
                err.jspError(n, "jsp.error.missing.tagInfo", n.getName());
            }

            /*
             * Make sure all required attributes are present
             */
            TagAttributeInfo[] tldAttrs = tagInfo.getAttributes();
            Attributes attrs = n.getAttributes();
            for (int i=0; i<tldAttrs.length; i++) {
                if (tldAttrs[i].isRequired()
                    && attrs.getValue(tldAttrs[i].getName()) == null) {
                    err.jspError(n, "jsp.error.missing_attribute",
View Full Code Here


        }

        public void visit(Node.CustomTag n) throws JasperException {
            TagLibraryInfo tagLibInfo = (TagLibraryInfo)
                pageInfo.getTagLibraries().get(n.getPrefix());
            TagInfo tagInfo = tagLibInfo.getTag(n.getShortName());
            if (tagInfo == null) {
                err.jspError(n, "jsp.error.missing.tagInfo", n.getName());
            }

            if (!tagInfo.isValid(n.getTagData())) {
                err.jspError(n, "jsp.error.invalid.attributes");
            }

            visitBody(n);
        }
View Full Code Here

     * @param shortname The short name (no prefix) of the tag
     * @returns the TagInfo for that tag.
     */

    public TagInfo getTag(String shortname) {
        TagInfo tags[] = getTags();

        if (tags == null || tags.length == 0) {
            System.err.println("No tags");
            return null;
        }
View Full Code Here

  private void checkXmlAttributes(Node.CustomTag n,
          Node.JspAttribute[] jspAttrs,
          Hashtable tagDataAttrs)
          throws JasperException {

      TagInfo tagInfo = n.getTagInfo();
      if (tagInfo == null) {
    err.jspError(n, "jsp.error.missing.tagInfo", n.getQName());
      }
      TagAttributeInfo[] tldAttrs = tagInfo.getAttributes();
      Attributes attrs = n.getAttributes();

      for (int i=0; attrs != null && i<attrs.getLength(); i++) {
    boolean found = false;
    for (int j=0; tldAttrs != null && j<tldAttrs.length; j++) {
        if (attrs.getLocalName(i).equals(tldAttrs[j].getName())
          && (attrs.getURI(i) == null
        || attrs.getURI(i).length() == 0
        || attrs.getURI(i).equals(n.getURI()))) {
      if (tldAttrs[j].canBeRequestTime()) {
                            Class expectedType = String.class;
                            try {
                                String typeStr = tldAttrs[j].getTypeName();
                                if( tldAttrs[j].isFragment() ) {
                                    expectedType = JspFragment.class;
                                }
                                else if( typeStr != null ) {
                                    expectedType = JspUtil.toClass(typeStr,
                   loader);
                                }
                                jspAttrs[i]
                                    = getJspAttribute(attrs.getQName(i),
                                                      attrs.getURI(i),
                                                      attrs.getLocalName(i),
                                                      attrs.getValue(i),
                                                      expectedType,
                                                      n,
                                                      false);
                            } catch (ClassNotFoundException e) {
                                err.jspError(n,
                                    "jsp.error.unknown_attribute_type",
                                    tldAttrs[j].getName(),
                                    tldAttrs[j].getTypeName() );
                            }
      } else {
          // Attribute does not accept any expressions.
          // Make sure its value does not contain any.
          if (isExpression(n, attrs.getValue(i))) {
                                err.jspError(n,
                "jsp.error.attribute.custom.non_rt_with_expr",
               tldAttrs[j].getName());
          }
          jspAttrs[i]
        = new Node.JspAttribute(attrs.getQName(i),
              attrs.getURI(i),
              attrs.getLocalName(i),
              attrs.getValue(i),
              false,
              null,
              false);
      }
      if (jspAttrs[i].isExpression()) {
          tagDataAttrs.put(attrs.getQName(i),
               TagData.REQUEST_TIME_VALUE);
      } else {
          tagDataAttrs.put(attrs.getQName(i),
               attrs.getValue(i));
      }
      found = true;
      break;
        }
    }
    if (!found) {
        if (tagInfo.hasDynamicAttributes()) {
      jspAttrs[i] = getJspAttribute(attrs.getQName(i),
                  attrs.getURI(i),
                  attrs.getLocalName(i),
                  attrs.getValue(i),
                  java.lang.Object.class,
View Full Code Here

            Node.JspAttribute[] jspAttrs,
            int start,
            Hashtable tagDataAttrs)
          throws JasperException {

      TagInfo tagInfo = n.getTagInfo();
      if (tagInfo == null) {
    err.jspError(n, "jsp.error.missing.tagInfo", n.getQName());
      }
      TagAttributeInfo[] tldAttrs = tagInfo.getAttributes();
            Node.Nodes naNodes = n.getNamedAttributeNodes();

      for (int i=0; i<naNodes.size(); i++) {
                Node.NamedAttribute na = (Node.NamedAttribute)
        naNodes.getNode(i);
    boolean found = false;
    for (int j=0; j<tldAttrs.length; j++) {
        /*
         * See above comment about namespace matches. For named
         * attributes, we use the prefix instead of URI as the
         * match criterion, because in the case of a JSP document,
         * we'd have to keep track of which namespaces are in scope
         * when parsing a named attribute, in order to determine
         * the URI that the prefix of the named attribute's name
         * matches to.
         */
        String attrPrefix = na.getPrefix();
        if (na.getLocalName().equals(tldAttrs[j].getName())
          && (attrPrefix == null || attrPrefix.length() == 0
        || attrPrefix.equals(n.getPrefix()))) {
      jspAttrs[start + i] = new Node.JspAttribute(na, false);
      NamedAttributeVisitor nav = null;
      if (na.getBody() != null) {
          nav = new NamedAttributeVisitor();
          na.getBody().visit(nav);
      }
      if (nav != null && nav.hasDynamicContent()) {
          tagDataAttrs.put(na.getName(),
               TagData.REQUEST_TIME_VALUE);
      } else {
          tagDataAttrs.put(na.getName(), na.getText());   
      }
      found = true;
      break;
        }
    }
    if (!found) {
        if (tagInfo.hasDynamicAttributes()) {
      jspAttrs[start + i] = new Node.JspAttribute(na, true);
        } else {
      err.jspError(n, "jsp.error.bad_attribute",
             na.getName(), n.getLocalName());
        }
View Full Code Here

      this.pageInfo = compiler.getPageInfo();
      this.err = compiler.getErrorDispatcher();
  }

  public void visit(Node.CustomTag n) throws JasperException {
      TagInfo tagInfo = n.getTagInfo();
      if (tagInfo == null) {
    err.jspError(n, "jsp.error.missing.tagInfo", n.getQName());
      }

      ValidationMessage[] errors = tagInfo.validate(n.getTagData());
            if (errors != null && errors.length != 0) {
    StringBuffer errMsg = new StringBuffer();
                errMsg.append("<h3>");
                errMsg.append(Localizer.getMessage("jsp.error.tei.invalid.attributes",
               n.getQName()));
View Full Code Here

      visitBody(n);
        }

  public void visit(Node.CustomTag n) throws JasperException {

      TagInfo tagInfo = n.getTagInfo();
      if (tagInfo == null) {
    err.jspError(n, "jsp.error.missing.tagInfo", n.getQName());
      }

      /*
       * The bodyconet of a SimpleTag cannot be JSP.
       */
      if (n.implementsSimpleTag() &&
                tagInfo.getBodyContent().equalsIgnoreCase(TagInfo.BODY_CONTENT_JSP)) {
                err.jspError(n, "jsp.error.simpletag.badbodycontent",
                        tagInfo.getTagClassName());
      }

      /*
       * If the tag handler declares in the TLD that it supports dynamic
       * attributes, it also must implement the DynamicAttributes
       * interface.
       */
      if (tagInfo.hasDynamicAttributes()
        && !n.implementsDynamicAttributes()) {
    err.jspError(n, "jsp.error.dynamic.attributes.not.implemented",
           n.getQName());
      }

      /*
       * Make sure all required attributes are present, either as
             * attributes or named attributes (<jsp:attribute>).
        * Also make sure that the same attribute is not specified in
       * both attributes or named attributes.
       */
      TagAttributeInfo[] tldAttrs = tagInfo.getAttributes();
      String customActionUri = n.getURI();
      Attributes attrs = n.getAttributes();
      int attrsSize = (attrs == null) ? 0 : attrs.getLength();
      for (int i=0; i<tldAttrs.length; i++) {
    String attr = null;
    if (attrs != null) {
        attr = attrs.getValue(tldAttrs[i].getName());
        if (attr == null) {
      attr = attrs.getValue(customActionUri,
                tldAttrs[i].getName());
        }
    }
    Node.NamedAttribute na =
      n.getNamedAttributeNode(tldAttrs[i].getName());
   
    if (tldAttrs[i].isRequired() && attr == null && na == null) {
        err.jspError(n, "jsp.error.missing_attribute",
         tldAttrs[i].getName(), n.getLocalName());
    }
    if (attr != null && na != null) {
        err.jspError(n, "jsp.error.duplicate.name.jspattribute",
      tldAttrs[i].getName());
    }
      }

            Node.Nodes naNodes = n.getNamedAttributeNodes();
      int jspAttrsSize = naNodes.size() + attrsSize;
      Node.JspAttribute[] jspAttrs = null;
      if (jspAttrsSize > 0) {
    jspAttrs = new Node.JspAttribute[jspAttrsSize];
      }
      Hashtable tagDataAttrs = new Hashtable(attrsSize);

      checkXmlAttributes(n, jspAttrs, tagDataAttrs);
            checkNamedAttributes(n, jspAttrs, attrsSize, tagDataAttrs);

      TagData tagData = new TagData(tagDataAttrs);

      // JSP.C1: It is a (translation time) error for an action that
      // has one or more variable subelements to have a TagExtraInfo
      // class that returns a non-null object.
      TagExtraInfo tei = tagInfo.getTagExtraInfo();
      if (tei != null
        && tei.getVariableInfo(tagData) != null
        && tei.getVariableInfo(tagData).length > 0
        && tagInfo.getTagVariableInfos().length > 0) {
    err.jspError("jsp.error.non_null_tei_and_var_subelems",
           n.getQName());
      }

      n.setTagData(tagData);
View Full Code Here

        TagLibraryInfo tagLibInfo = pageInfo.getTaglib(uri);
        if (tagLibInfo == null) {
            return null;
        }

        TagInfo tagInfo = tagLibInfo.getTag(localName);
        TagFileInfo tagFileInfo = tagLibInfo.getTagFile(localName);
        if (tagInfo == null && tagFileInfo == null) {
            throw new SAXException(
                Localizer.getMessage("jsp.error.xml.bad_tag", localName, uri));
        }
        Class tagHandlerClass = null;
        if (tagInfo != null) {
            String handlerClassName = tagInfo.getTagClassName();
            try {
                tagHandlerClass =
                    ctxt.getClassLoader().loadClass(handlerClassName);
            } catch (Exception e) {
                throw new SAXException(
View Full Code Here

        TagVariableInfo[] tagVariableInfos
            = new TagVariableInfo[variableVector.size()];
        variableVector.copyInto(tagVariableInfos);

        TagInfo taginfo = new TagInfo(tagName,
                                      tagClassName,
                                      bodycontent,
                                      info,
                                      this,
                                      tei,
View Full Code Here

            ctxt.getTagFileJarUrls().put(path, jarFileUrl);
        } else if (!path.startsWith("/WEB-INF/tags")) {
            err.jspError("jsp.error.tagfile.illegalPath", path);
        }

        TagInfo tagInfo
            = TagFileProcessor.parseTagFileDirectives(parserController, name,
                                                      path, this);
        return new TagFileInfo(name, path, tagInfo);
    }
View Full Code Here

TOP

Related Classes of javax.servlet.jsp.tagext.TagInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.