javax.servlet.jsp.tagext.ValidationMessage Java Examples

The following examples show how to use javax.servlet.jsp.tagext.ValidationMessage. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DebugValidator.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * Validate a JSP page.  This will get invoked once per directive in the
 * JSP page.  This method will return <code>null</code> if the page is
 * valid; otherwise the method should return an array of
 * <code>ValidationMessage</code> objects.  An array of length zero is
 * also interpreted as no errors.
 *
 * @param prefix The value of the prefix argument in this directive
 * @param uri The value of the URI argument in this directive
 * @param page The page data for this page
 */
@Override
public ValidationMessage[] validate(String prefix, String uri,
                                    PageData page) {

    System.out.println("---------- Prefix=" + prefix + " URI=" + uri +
                       "----------");

    InputStream is = page.getInputStream();
    while (true) {
        try {
            int ch = is.read();
            if (ch < 0)
                break;
            System.out.print((char) ch);
        } catch (IOException e) {
            break;
        }
    }
    System.out.println();
    System.out.println("-----------------------------------------------");
    return null;

}
 
Example #2
Source File: TagLibraryInfoImpl.java    From packagedrone with Eclipse Public License 1.0 6 votes vote down vote up
/**
    * Translation-time validation of the XML document
    * associated with the JSP page.
    * This is a convenience method on the associated 
    * TagLibraryValidator class.
    *
    * @param thePage The JSP page object
    * @return A string indicating whether the page is valid or not.
    */
   public ValidationMessage[] validate(PageData thePage) {
TagLibraryValidator tlv = getTagLibraryValidator();
if (tlv == null) return null;

       String uri = getURI();
       if (uri.startsWith("/")) {
           uri = URN_JSPTLD + uri;
       }

       ValidationMessage[] messages = tlv.validate(getPrefixString(), uri,
                                                   thePage);
       tlv.release();

       return messages;
   }
 
Example #3
Source File: DebugValidator.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * Validate a JSP page.  This will get invoked once per directive in the
 * JSP page.  This method will return <code>null</code> if the page is
 * valid; otherwise the method should return an array of
 * <code>ValidationMessage</code> objects.  An array of length zero is
 * also interpreted as no errors.
 *
 * @param prefix The value of the prefix argument in this directive
 * @param uri The value of the URI argument in this directive
 * @param page The page data for this page
 */
@Override
public ValidationMessage[] validate(String prefix, String uri,
                                    PageData page) {

    System.out.println("---------- Prefix=" + prefix + " URI=" + uri +
                       "----------");

    InputStream is = page.getInputStream();
    while (true) {
        try {
            int ch = is.read();
            if (ch < 0)
                break;
            System.out.print((char) ch);
        } catch (IOException e) {
            break;
        }
    }
    System.out.println();
    System.out.println("-----------------------------------------------");
    return null;

}
 
Example #4
Source File: DebugValidator.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * Validate a JSP page.  This will get invoked once per directive in the
 * JSP page.  This method will return <code>null</code> if the page is
 * valid; otherwise the method should return an array of
 * <code>ValidationMessage</code> objects.  An array of length zero is
 * also interpreted as no errors.
 *
 * @param prefix The value of the prefix argument in this directive
 * @param uri The value of the URI argument in this directive
 * @param page The page data for this page
 */
@Override
public ValidationMessage[] validate(String prefix, String uri,
                                    PageData page) {

    System.out.println("---------- Prefix=" + prefix + " URI=" + uri +
                       "----------");

    InputStream is = page.getInputStream();
    while (true) {
        try {
            int ch = is.read();
            if (ch < 0)
                break;
            System.out.print((char) ch);
        } catch (IOException e) {
            break;
        }
    }
    System.out.println();
    System.out.println("-----------------------------------------------");
    return (null);

}
 
Example #5
Source File: DebugValidator.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * Validate a JSP page.  This will get invoked once per directive in the
 * JSP page.  This method will return <code>null</code> if the page is
 * valid; otherwise the method should return an array of
 * <code>ValidationMessage</code> objects.  An array of length zero is
 * also interpreted as no errors.
 *
 * @param prefix The value of the prefix argument in this directive
 * @param uri The value of the URI argument in this directive
 * @param page The page data for this page
 */
@Override
public ValidationMessage[] validate(String prefix, String uri,
                                    PageData page) {

    System.out.println("---------- Prefix=" + prefix + " URI=" + uri +
                       "----------");

    InputStream is = page.getInputStream();
    while (true) {
        try {
            int ch = is.read();
            if (ch < 0)
                break;
            System.out.print((char) ch);
        } catch (IOException e) {
            break;
        }
    }
    System.out.println();
    System.out.println("-----------------------------------------------");
    return (null);

}
 
Example #6
Source File: DebugValidator.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * Validate a JSP page.  This will get invoked once per directive in the
 * JSP page.  This method will return <code>null</code> if the page is
 * valid; otherwise the method should return an array of
 * <code>ValidationMessage</code> objects.  An array of length zero is
 * also interpreted as no errors.
 *
 * @param prefix The value of the prefix argument in this directive
 * @param uri The value of the URI argument in this directive
 * @param page The page data for this page
 */
@Override
public ValidationMessage[] validate(String prefix, String uri,
                                    PageData page) {

    System.out.println("---------- Prefix=" + prefix + " URI=" + uri +
                       "----------");

    InputStream is = page.getInputStream();
    while (true) {
        try {
            int ch = is.read();
            if (ch < 0)
                break;
            System.out.print((char) ch);
        } catch (IOException e) {
            break;
        }
    }
    System.out.println();
    System.out.println("-----------------------------------------------");
    return (null);

}
 
Example #7
Source File: Validator.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Override
public void visit(Node.CustomTag n) throws JasperException {
    TagInfo tagInfo = n.getTagInfo();
    if (tagInfo == null) {
        err.jspError(n, "jsp.error.missing.tagInfo", n.getQName());
    }

    @SuppressWarnings("null") // tagInfo can't be null here
    ValidationMessage[] errors = tagInfo.validate(n.getTagData());
    if (errors != null && errors.length != 0) {
        StringBuilder errMsg = new StringBuilder();
        errMsg.append("<h3>");
        errMsg.append(Localizer.getMessage(
                "jsp.error.tei.invalid.attributes", n.getQName()));
        errMsg.append("</h3>");
        for (int i = 0; i < errors.length; i++) {
            errMsg.append("<p>");
            if (errors[i].getId() != null) {
                errMsg.append(errors[i].getId());
                errMsg.append(": ");
            }
            errMsg.append(errors[i].getMessage());
            errMsg.append("</p>");
        }

        err.jspError(n, errMsg.toString());
    }

    visitBody(n);
}
 
Example #8
Source File: Validator.java    From packagedrone with Eclipse Public License 1.0 5 votes vote down vote up
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) {
	StringBuilder errMsg = new StringBuilder();
               errMsg.append("<h3>");
               errMsg.append(Localizer.getMessage("jsp.error.tei.invalid.attributes",
					   n.getQName()));
               errMsg.append("</h3>");
               for (int i=0; i<errors.length; i++) {
                   errMsg.append("<p>");
	    if (errors[i].getId() != null) {
		errMsg.append(errors[i].getId());
		errMsg.append(": ");
	    }
                   errMsg.append(errors[i].getMessage());
                   errMsg.append("</p>");
               }

	err.jspError(n, errMsg.toString());
           }

    visitBody(n);
}
 
Example #9
Source File: PagerTagExtraInfo.java    From feilong-taglib with Apache License 2.0 5 votes vote down vote up
@Override
// JSP 2.0 and higher containers call validate() instead of isValid().
// The default implementation of this method is to call isValid().

// If isValid() returns false, a generic ValidationMessage[] is returned indicating isValid() returned false.
public ValidationMessage[] validate(TagData tagData){
    if (LOGGER.isDebugEnabled()){
        Map<String, Object> map = getTagDataAttributeMap(tagData);
        LOGGER.debug(JsonUtil.format(map));
    }
    return super.validate(tagData);
}
 
Example #10
Source File: TagLibraryInfoImpl.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Translation-time validation of the XML document associated with the JSP
 * page. This is a convenience method on the associated TagLibraryValidator
 * class.
 * 
 * @param thePage
 *            The JSP page object
 * @return A string indicating whether the page is valid or not.
 */
public ValidationMessage[] validate(PageData thePage) {
    TagLibraryValidator tlv = getTagLibraryValidator();
    if (tlv == null)
        return null;

    String uri = getURI();
    if (uri.startsWith("/")) {
        uri = URN_JSPTLD + uri;
    }

    return tlv.validate(getPrefixString(), uri, thePage);
}
 
Example #11
Source File: Validator.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Override
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) {
        StringBuilder errMsg = new StringBuilder();
        errMsg.append("<h3>");
        errMsg.append(Localizer.getMessage(
                "jsp.error.tei.invalid.attributes", n.getQName()));
        errMsg.append("</h3>");
        for (int i = 0; i < errors.length; i++) {
            errMsg.append("<p>");
            if (errors[i].getId() != null) {
                errMsg.append(errors[i].getId());
                errMsg.append(": ");
            }
            errMsg.append(errors[i].getMessage());
            errMsg.append("</p>");
        }

        err.jspError(n, errMsg.toString());
    }

    visitBody(n);
}
 
Example #12
Source File: TagLibraryInfoImpl.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Translation-time validation of the XML document associated with the JSP
 * page. This is a convenience method on the associated TagLibraryValidator
 * class.
 * 
 * @param thePage
 *            The JSP page object
 * @return A string indicating whether the page is valid or not.
 */
public ValidationMessage[] validate(PageData thePage) {
    TagLibraryValidator tlv = getTagLibraryValidator();
    if (tlv == null)
        return null;

    String uri = getURI();
    if (uri.startsWith("/")) {
        uri = URN_JSPTLD + uri;
    }

    return tlv.validate(getPrefixString(), uri, thePage);
}
 
Example #13
Source File: Validator.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Override
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) {
        StringBuilder errMsg = new StringBuilder();
        errMsg.append("<h3>");
        errMsg.append(Localizer.getMessage(
                "jsp.error.tei.invalid.attributes", n.getQName()));
        errMsg.append("</h3>");
        for (int i = 0; i < errors.length; i++) {
            errMsg.append("<p>");
            if (errors[i].getId() != null) {
                errMsg.append(errors[i].getId());
                errMsg.append(": ");
            }
            errMsg.append(errors[i].getMessage());
            errMsg.append("</p>");
        }

        err.jspError(n, errMsg.toString());
    }

    visitBody(n);
}
 
Example #14
Source File: TagLibraryInfoImpl.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * Translation-time validation of the XML document associated with the JSP
 * page. This is a convenience method on the associated TagLibraryValidator
 * class.
 *
 * @param thePage
 *            The JSP page object
 * @return A string indicating whether the page is valid or not.
 */
public ValidationMessage[] validate(PageData thePage) {
    TagLibraryValidator tlv = getTagLibraryValidator();
    if (tlv == null)
        return null;

    String uri = getURI();
    if (uri.startsWith("/")) {
        uri = URN_JSPTLD + uri;
    }

    return tlv.validate(getPrefixString(), uri, thePage);
}
 
Example #15
Source File: Validator.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
/**
 * Validate XML view against the TagLibraryValidator classes of all imported
 * tag libraries.
 */
private static void validateXmlView(PageData xmlView, Compiler compiler)
        throws JasperException {

    StringBuilder errMsg = null;
    ErrorDispatcher errDisp = compiler.getErrorDispatcher();

    for (Iterator<TagLibraryInfo> iter =
        compiler.getPageInfo().getTaglibs().iterator(); iter.hasNext();) {

        Object o = iter.next();
        if (!(o instanceof TagLibraryInfoImpl))
            continue;
        TagLibraryInfoImpl tli = (TagLibraryInfoImpl) o;

        ValidationMessage[] errors = tli.validate(xmlView);
        if ((errors != null) && (errors.length != 0)) {
            if (errMsg == null) {
                errMsg = new StringBuilder();
            }
            errMsg.append("<h3>");
            errMsg.append(Localizer.getMessage(
                    "jsp.error.tlv.invalid.page", tli.getShortName(),
                    compiler.getPageInfo().getJspFile()));
            errMsg.append("</h3>");
            for (int i = 0; i < errors.length; i++) {
                if (errors[i] != null) {
                    errMsg.append("<p>");
                    errMsg.append(errors[i].getId());
                    errMsg.append(": ");
                    errMsg.append(errors[i].getMessage());
                    errMsg.append("</p>");
                }
            }
        }
    }

    if (errMsg != null) {
        errDisp.jspError(errMsg.toString());
    }
}
 
Example #16
Source File: Validator.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
/**
 * Validate XML view against the TagLibraryValidator classes of all imported
 * tag libraries.
 */
private static void validateXmlView(PageData xmlView, Compiler compiler)
        throws JasperException {

    StringBuilder errMsg = null;
    ErrorDispatcher errDisp = compiler.getErrorDispatcher();

    for (Iterator<TagLibraryInfo> iter =
        compiler.getPageInfo().getTaglibs().iterator(); iter.hasNext();) {

        Object o = iter.next();
        if (!(o instanceof TagLibraryInfoImpl))
            continue;
        TagLibraryInfoImpl tli = (TagLibraryInfoImpl) o;

        ValidationMessage[] errors = tli.validate(xmlView);
        if ((errors != null) && (errors.length != 0)) {
            if (errMsg == null) {
                errMsg = new StringBuilder();
            }
            errMsg.append("<h3>");
            errMsg.append(Localizer.getMessage(
                    "jsp.error.tlv.invalid.page", tli.getShortName(),
                    compiler.getPageInfo().getJspFile()));
            errMsg.append("</h3>");
            for (int i = 0; i < errors.length; i++) {
                if (errors[i] != null) {
                    errMsg.append("<p>");
                    errMsg.append(errors[i].getId());
                    errMsg.append(": ");
                    errMsg.append(errors[i].getMessage());
                    errMsg.append("</p>");
                }
            }
        }
    }

    if (errMsg != null) {
        errDisp.jspError(errMsg.toString());
    }
}
 
Example #17
Source File: Validator.java    From packagedrone with Eclipse Public License 1.0 4 votes vote down vote up
/**
    * Validate XML view against the TagLibraryValidator classes of all
    * imported tag libraries.
    */
   private static void validateXmlView(PageData xmlView, Compiler compiler)
        throws JasperException {

StringBuilder errMsg = null;
ErrorDispatcher errDisp = compiler.getErrorDispatcher();

for (Iterator<TagLibraryInfo> iter = 
                    compiler.getPageInfo().getTaglibs().iterator();
         iter.hasNext(); ) {

    TagLibraryInfo o = iter.next();
    if (!(o instanceof TagLibraryInfoImpl))
	continue;
    TagLibraryInfoImpl tli = (TagLibraryInfoImpl) o;

    ValidationMessage[] errors = tli.validate(xmlView);
           if ((errors != null) && (errors.length != 0)) {
               if (errMsg == null) {
	    errMsg = new StringBuilder();
	}
               errMsg.append("<h3>");
               errMsg.append(Localizer.getMessage("jsp.error.tlv.invalid.page",
					   tli.getShortName()));
               errMsg.append("</h3>");
               for (int i=0; i<errors.length; i++) {
	    if (errors[i] != null) {
		errMsg.append("<p>");
		errMsg.append(errors[i].getId());
		errMsg.append(": ");
		errMsg.append(errors[i].getMessage());
		errMsg.append("</p>");
	    }
               }
           }
       }

if (errMsg != null) {
           errDisp.jspError(errMsg.toString());
}
   }
 
Example #18
Source File: Validator.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
/**
 * Validate XML view against the TagLibraryValidator classes of all imported
 * tag libraries.
 */
private static void validateXmlView(PageData xmlView, Compiler compiler)
        throws JasperException {

    StringBuilder errMsg = null;
    ErrorDispatcher errDisp = compiler.getErrorDispatcher();

    for (Iterator<TagLibraryInfo> iter =
        compiler.getPageInfo().getTaglibs().iterator(); iter.hasNext();) {

        Object o = iter.next();
        if (!(o instanceof TagLibraryInfoImpl))
            continue;
        TagLibraryInfoImpl tli = (TagLibraryInfoImpl) o;

        ValidationMessage[] errors = tli.validate(xmlView);
        if ((errors != null) && (errors.length != 0)) {
            if (errMsg == null) {
                errMsg = new StringBuilder();
            }
            errMsg.append("<h3>");
            errMsg.append(Localizer.getMessage(
                    "jsp.error.tlv.invalid.page", tli.getShortName(),
                    compiler.getPageInfo().getJspFile()));
            errMsg.append("</h3>");
            for (int i = 0; i < errors.length; i++) {
                if (errors[i] != null) {
                    errMsg.append("<p>");
                    errMsg.append(errors[i].getId());
                    errMsg.append(": ");
                    errMsg.append(errors[i].getMessage());
                    errMsg.append("</p>");
                }
            }
        }
    }

    if (errMsg != null) {
        errDisp.jspError(errMsg.toString());
    }
}