import java.util.Hashtable;
import java.util.Iterator;
-import javax.el.ELContext;
import javax.el.ELException;
import javax.el.ExpressionFactory;
import javax.el.FunctionMapper;
&& (attrs.getURI(i) == null
|| attrs.getURI(i).length() == 0 || attrs
.getURI(i).equals(n.getURI()))) {
- boolean el = true;
- boolean deferredValue = false;
- if (!tagInfo.getTagLibrary().getRequiredVersion().equals("2.0")
- && attrs.getValue(i).indexOf("#{") != -1) {
- el = false;
- if (!pageInfo.isELIgnored() && !pageInfo.isDeferredSyntaxAllowedAsLiteral()) {
- deferredValue = true;
+ boolean checkDeferred = !tagInfo.getTagLibrary().getRequiredVersion().equals("2.0");
+ boolean deferred = false;
+ boolean deferredValueIsLiteral = false;
+ boolean expression = isExpression(n, attrs.getValue(i), checkDeferred);
+ if (checkDeferred && attrs.getValue(i).indexOf("#{") != -1) {
+ deferred = true;
+ if (pageInfo.isELIgnored()) {
+ deferredValueIsLiteral = true;
}
}
- if ((el && tldAttrs[j].canBeRequestTime())
- || (deferredValue && tldAttrs[j].isDeferredMethod()) // JSP 2.1
- || (deferredValue && tldAttrs[j].isDeferredValue())) { // JSP 2.1
- 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);
+
+ /*System.out.println("attrs.getLocalName(i): " + attrs.getLocalName(i));
+ System.out.println("tldAttrs[j].canBeRequestTime(): " + tldAttrs[j].canBeRequestTime());
+ System.out.println("expression: " + expression);
+ System.out.println("tldAttrs[j].isDeferredMethod(): " + tldAttrs[j].isDeferredMethod());
+ System.out.println("tldAttrs[j].isDeferredValue(): " + tldAttrs[j].isDeferredValue());*/
+
+ if (tldAttrs[j].canBeRequestTime()
+ || tldAttrs[j].isDeferredMethod() || tldAttrs[j].isDeferredValue()) { // JSP 2.1
+
+ if (!expression) {
+
+ if (deferredValueIsLiteral && !pageInfo.isDeferredSyntaxAllowedAsLiteral()) {
+ err.jspError(n, "jsp.error.attribute.custom.non_rt_with_expr",
+ tldAttrs[j].getName());
+ }
+
+ if (tldAttrs[j].isDeferredMethod()) {
+ // The String litteral must be castable to what is declared as type
+ // for the attribute
+
+ }
+ if (tldAttrs[j].isDeferredValue()) {
+ // The String litteral must be castable to what is declared as type
+ // for the attribute
+
+ }
+
+ jspAttrs[i] = new Node.JspAttribute(tldAttrs[j],
+ attrs.getQName(i), attrs.getURI(i), attrs
+ .getLocalName(i),
+ attrs.getValue(i), false, null, false);
+ } else {
+
+ if (deferred && !tldAttrs[j].isDeferredMethod() && !tldAttrs[j].isDeferredValue()) {
+ // No deferred expressions allowed for this attribute
+ err.jspError(n, "jsp.error.attribute.custom.non_rt_with_expr",
+ tldAttrs[j].getName());
+ }
+ if (!deferred && (tldAttrs[j].isDeferredMethod() || tldAttrs[j].isDeferredValue())) {
+ // Only deferred expressions are allowed for this attribute
+ err.jspError(n, "jsp.error.attribute.custom.non_rt_with_expr",
+ tldAttrs[j].getName());
+ }
+
+ 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(tldAttrs[j],
+ 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());
}
- jspAttrs[i] = getJspAttribute(tldAttrs[j],
- 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),
- !tagInfo.getTagLibrary().getRequiredVersion().equals("2.0"))) {
+ if (expression) {
err.jspError(n, "jsp.error.attribute.custom.non_rt_with_expr",
tldAttrs[j].getName());
}
// expression(s)
ELNode.Nodes el = ELParser.parse(value);
- if (el.containsEL() && !pageInfo.isELIgnored()) {
+ if (el.containsEL() && !pageInfo.isELIgnored()
+ && (!pageInfo.isDeferredSyntaxAllowedAsLiteral() && value.startsWith("#{"))) {
validateFunctions(el, n);
result = new Node.JspAttribute(tai, qName, uri,