Java Code Examples for javax.servlet.jsp.tagext.TagAttributeInfo#canBeRequestTime()

The following examples show how to use javax.servlet.jsp.tagext.TagAttributeInfo#canBeRequestTime() . 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: TagFileProcessor.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * Perform miscellaneous checks after the nodes are visited.
 */
void postCheck() throws JasperException {
    // Check that var.name-from-attributes has valid values.
    for (Entry<String, NameEntry> entry : nameFromTable.entrySet()) {
        String key = entry.getKey();
        NameEntry nameEntry = nameTable.get(key);
        NameEntry nameFromEntry = entry.getValue();
        Node nameFromNode = nameFromEntry.getNode();
        if (nameEntry == null) {
            err.jspError(nameFromNode,
                    "jsp.error.tagfile.nameFrom.noAttribute", key);
        } else {
            Node node = nameEntry.getNode();
            TagAttributeInfo tagAttr = nameEntry.getTagAttributeInfo();
            if (!"java.lang.String".equals(tagAttr.getTypeName())
                    || !tagAttr.isRequired()
                    || tagAttr.canBeRequestTime()) {
                err.jspError(nameFromNode,
                        "jsp.error.tagfile.nameFrom.badAttribute",
                        key, Integer.toString(node.getStart()
                                .getLineNumber()));
            }
        }
    }
}
 
Example 2
Source File: TagFileProcessor.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * Perform miscellaneous checks after the nodes are visited.
 */
void postCheck() throws JasperException {
    // Check that var.name-from-attributes has valid values.
    for (Entry<String, NameEntry> entry : nameFromTable.entrySet()) {
        String key = entry.getKey();
        NameEntry nameEntry = nameTable.get(key);
        NameEntry nameFromEntry = entry.getValue();
        Node nameFromNode = nameFromEntry.getNode();
        if (nameEntry == null) {
            err.jspError(nameFromNode,
                    "jsp.error.tagfile.nameFrom.noAttribute", key);
        } else {
            Node node = nameEntry.getNode();
            TagAttributeInfo tagAttr = nameEntry.getTagAttributeInfo();
            if (!"java.lang.String".equals(tagAttr.getTypeName())
                    || !tagAttr.isRequired()
                    || tagAttr.canBeRequestTime()) {
                err.jspError(nameFromNode,
                        "jsp.error.tagfile.nameFrom.badAttribute",
                        key, Integer.toString(node.getStart()
                                .getLineNumber()));
            }
        }
    }
}
 
Example 3
Source File: TagFileProcessor.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * Perform miscellaneous checks after the nodes are visited.
 */
void postCheck() throws JasperException {
    // Check that var.name-from-attributes has valid values.
    for (Entry<String, NameEntry> entry : nameFromTable.entrySet()) {
        String key = entry.getKey();
        NameEntry nameEntry = nameTable.get(key);
        NameEntry nameFromEntry = entry.getValue();
        Node nameFromNode = nameFromEntry.getNode();
        if (nameEntry == null) {
            err.jspError(nameFromNode,
                    "jsp.error.tagfile.nameFrom.noAttribute", key);
        } else {
            Node node = nameEntry.getNode();
            TagAttributeInfo tagAttr = nameEntry.getTagAttributeInfo();
            if (!"java.lang.String".equals(tagAttr.getTypeName())
                    || !tagAttr.isRequired()
                    || tagAttr.canBeRequestTime()) {
                err.jspError(nameFromNode,
                        "jsp.error.tagfile.nameFrom.badAttribute",
                        key, Integer.toString(node.getStart()
                                .getLineNumber()));
            }
        }
    }
}
 
Example 4
Source File: TagFileProcessor.java    From packagedrone with Eclipse Public License 1.0 5 votes vote down vote up
/**
    * Perform miscelleaneous checks after the nodes are visited.
    */
   void postCheck() throws JasperException {
       // Check that var.name-from-attributes has valid values.
Iterator iter = nameFromTable.keySet().iterator();
       while (iter.hasNext()) {
           String nameFrom = (String) iter.next();
           NameEntry nameEntry = nameTable.get(nameFrom);
           NameEntry nameFromEntry = nameFromTable.get(nameFrom);
           Node nameFromNode = nameFromEntry.getNode();
           if (nameEntry == null) {
               err.jspError(nameFromNode,
                            "jsp.error.tagfile.nameFrom.noAttribute",
                            nameFrom);
           } else {
               Node node = nameEntry.getNode();
               TagAttributeInfo tagAttr = nameEntry.getTagAttributeInfo();
               if (! "java.lang.String".equals(tagAttr.getTypeName())
                       || ! tagAttr.isRequired()
                       || tagAttr.canBeRequestTime()){
                   err.jspError(nameFromNode,
                       "jsp.error.tagfile.nameFrom.badAttribute",
                       nameFrom,
                       Integer.toString(node.getStart().getLineNumber()));
                }
           }
       }
   }
 
Example 5
Source File: Validator.java    From packagedrone with Eclipse Public License 1.0 4 votes vote down vote up
private void checkSetter(Node.CustomTag n, TagAttributeInfo tldattr) 
                throws JasperException {

            Class handler = n.getTagHandlerClass();
            if (handler == null) {
                // Handler unknown.  Maybe tag file?
                return;
            }

            String handlerName = handler.getName();
            String property = tldattr.getName();
            Method setter = null;

            try {
                setter = JspRuntimeLibrary.getWriteMethod(handler, property);
            } catch (Exception ex) {
            }
            if (setter == null) {
                err.jspError(n, "jsp.error.setter.none", handlerName,
                             property);
            }
            Class setterType = setter.getParameterTypes()[0];
            String typeName = setterType.getName();
            if (tldattr.isDeferredValue()) {
                if (tldattr.canBeRequestTime()) {
                    if (! "java.lang.Object".equals(typeName)) {
                        err.jspError(n, "jsp.error.setter.notobject",
                            handlerName, property);
                    }
                    return;
                }
                if (! "javax.el.ValueExpression".equals(typeName)) {
                    err.jspError(n, "jsp.error.setter.notvalueexpression",
                        handlerName, property);
                }
                return;
            }
            if (tldattr.isDeferredMethod()) {
                if (! "javax.el.MethodExpression".equals(typeName)) {
                    err.jspError(n, "jsp.error.setter.notmethodexpression",
                        handlerName, property);
                }
                return;
            }
/* Temporarily removed, as it breaks some JSF applications.  Should be
   able to refine the check.
            String tldType = tldattr.getTypeName();
            if (tldType != null && ! tldType.equals(typeName)) {
                err.jspError(n, "jsp.error.setter.notequal",
                    handlerName, property);
            }
*/
        }