Search in sources :

Example 1 with TagLibraryValidator

use of javax.servlet.jsp.tagext.TagLibraryValidator in project tomcat by apache.

the class TagLibraryInfoImpl method validate.

/**
     * 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);
}
Also used : TagLibraryValidator(javax.servlet.jsp.tagext.TagLibraryValidator)

Example 2 with TagLibraryValidator

use of javax.servlet.jsp.tagext.TagLibraryValidator in project tomcat by apache.

the class TagLibraryInfoImpl method createValidator.

private TagLibraryValidator createValidator(ValidatorXml validatorXml) throws JasperException {
    if (validatorXml == null) {
        return null;
    }
    String validatorClass = validatorXml.getValidatorClass();
    if (validatorClass == null || validatorClass.isEmpty()) {
        return null;
    }
    Map<String, Object> initParams = new Hashtable<>();
    initParams.putAll(validatorXml.getInitParams());
    try {
        Class<?> tlvClass = ctxt.getClassLoader().loadClass(validatorClass);
        TagLibraryValidator tlv = (TagLibraryValidator) tlvClass.newInstance();
        tlv.setInitParameters(initParams);
        return tlv;
    } catch (Exception e) {
        err.jspError(e, "jsp.error.tlvclass.instantiation", validatorClass);
        return null;
    }
}
Also used : Hashtable(java.util.Hashtable) TagLibraryValidator(javax.servlet.jsp.tagext.TagLibraryValidator) URISyntaxException(java.net.URISyntaxException) JasperException(org.apache.jasper.JasperException) IOException(java.io.IOException)

Example 3 with TagLibraryValidator

use of javax.servlet.jsp.tagext.TagLibraryValidator in project sling by apache.

the class TagLibraryInfoImpl method validate.

/**
     * 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);
}
Also used : TagLibraryValidator(javax.servlet.jsp.tagext.TagLibraryValidator)

Example 4 with TagLibraryValidator

use of javax.servlet.jsp.tagext.TagLibraryValidator in project sling by apache.

the class TagLibraryInfoImpl method createValidator.

private TagLibraryValidator createValidator(TreeNode elem) throws JasperException {
    String validatorClass = null;
    Map initParams = new Hashtable();
    Iterator list = elem.findChildren();
    while (list.hasNext()) {
        TreeNode element = (TreeNode) list.next();
        String tname = element.getName();
        if ("validator-class".equals(tname))
            validatorClass = element.getBody();
        else if ("init-param".equals(tname)) {
            String[] initParam = createInitParam(element);
            initParams.put(initParam[0], initParam[1]);
        } else if (// Ignored elements
        "description".equals(tname) || false) {
        } else {
            if (log.isWarnEnabled()) {
                log.warn(Localizer.getMessage("jsp.warning.unknown.element.in.validator", tname));
            }
        }
    }
    TagLibraryValidator tlv = null;
    if (validatorClass != null && !validatorClass.equals("")) {
        try {
            Class tlvClass = ctxt.getClassLoader().loadClass(validatorClass);
            tlv = (TagLibraryValidator) tlvClass.newInstance();
        } catch (Exception e) {
            err.jspError("jsp.error.tlvclass.instantiation", validatorClass, e);
        }
    }
    if (tlv != null) {
        tlv.setInitParameters(initParams);
    }
    return tlv;
}
Also used : Hashtable(java.util.Hashtable) TreeNode(org.apache.sling.scripting.jsp.jasper.xmlparser.TreeNode) Iterator(java.util.Iterator) TagLibraryValidator(javax.servlet.jsp.tagext.TagLibraryValidator) Map(java.util.Map) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) JasperException(org.apache.sling.scripting.jsp.jasper.JasperException)

Aggregations

TagLibraryValidator (javax.servlet.jsp.tagext.TagLibraryValidator)4 IOException (java.io.IOException)2 Hashtable (java.util.Hashtable)2 FileNotFoundException (java.io.FileNotFoundException)1 URISyntaxException (java.net.URISyntaxException)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 JasperException (org.apache.jasper.JasperException)1 JasperException (org.apache.sling.scripting.jsp.jasper.JasperException)1 TreeNode (org.apache.sling.scripting.jsp.jasper.xmlparser.TreeNode)1