本文整理汇总了Java中javax.servlet.jsp.tagext.TagInfo.hasDynamicAttributes方法的典型用法代码示例。如果您正苦于以下问题:Java TagInfo.hasDynamicAttributes方法的具体用法?Java TagInfo.hasDynamicAttributes怎么用?Java TagInfo.hasDynamicAttributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.servlet.jsp.tagext.TagInfo
的用法示例。
在下文中一共展示了TagInfo.hasDynamicAttributes方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkNamedAttributes
import javax.servlet.jsp.tagext.TagInfo; //导入方法依赖的package包/类
private void checkNamedAttributes(Node.CustomTag n,
Node.JspAttribute[] jspAttrs, int start,
Hashtable<String, Object> 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,
tldAttrs[j], 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, null,
true);
} else {
err.jspError(n, "jsp.error.bad_attribute",
na.getName(), n.getLocalName());
}
}
}
}
示例2: getAttributeBodyType
import javax.servlet.jsp.tagext.TagInfo; //导入方法依赖的package包/类
/**
* Determine the body type of <jsp:attribute> from the enclosing node
*/
private String getAttributeBodyType(Node n, String name) {
if (n instanceof Node.CustomTag) {
TagInfo tagInfo = ((Node.CustomTag) n).getTagInfo();
TagAttributeInfo[] tldAttrs = tagInfo.getAttributes();
for (int i = 0; i < tldAttrs.length; i++) {
if (name.equals(tldAttrs[i].getName())) {
if (tldAttrs[i].isFragment()) {
return TagInfo.BODY_CONTENT_SCRIPTLESS;
}
if (tldAttrs[i].canBeRequestTime()) {
return TagInfo.BODY_CONTENT_JSP;
}
}
}
if (tagInfo.hasDynamicAttributes()) {
return TagInfo.BODY_CONTENT_JSP;
}
} else if (n instanceof Node.IncludeAction) {
if ("page".equals(name)) {
return TagInfo.BODY_CONTENT_JSP;
}
} else if (n instanceof Node.ForwardAction) {
if ("page".equals(name)) {
return TagInfo.BODY_CONTENT_JSP;
}
} else if (n instanceof Node.SetProperty) {
if ("value".equals(name)) {
return TagInfo.BODY_CONTENT_JSP;
}
} else if (n instanceof Node.UseBean) {
if ("beanName".equals(name)) {
return TagInfo.BODY_CONTENT_JSP;
}
} else if (n instanceof Node.PlugIn) {
if ("width".equals(name) || "height".equals(name)) {
return TagInfo.BODY_CONTENT_JSP;
}
} else if (n instanceof Node.ParamAction) {
if ("value".equals(name)) {
return TagInfo.BODY_CONTENT_JSP;
}
} else if (n instanceof Node.JspElement) {
return TagInfo.BODY_CONTENT_JSP;
}
return JAVAX_BODY_CONTENT_TEMPLATE_TEXT;
}
示例3: generateTagHandlerAttributes
import javax.servlet.jsp.tagext.TagInfo; //导入方法依赖的package包/类
/**
* Generates declarations for tag handler attributes, and defines the getter
* and setter methods for each.
*/
private void generateTagHandlerAttributes(TagInfo tagInfo) {
if (tagInfo.hasDynamicAttributes()) {
out.printil("private java.util.HashMap _jspx_dynamic_attrs = new java.util.HashMap();");
}
// Declare attributes
TagAttributeInfo[] attrInfos = tagInfo.getAttributes();
for (int i = 0; i < attrInfos.length; i++) {
out.printin("private ");
if (attrInfos[i].isFragment()) {
out.print("javax.servlet.jsp.tagext.JspFragment ");
} else {
out.print(JspUtil.toJavaSourceType(attrInfos[i].getTypeName()));
out.print(" ");
}
out.print(JspUtil.makeJavaIdentifierForAttribute(
attrInfos[i].getName()));
out.println(";");
}
out.println();
// Define attribute getter and setter methods
for (int i = 0; i < attrInfos.length; i++) {
String javaName =
JspUtil.makeJavaIdentifierForAttribute(attrInfos[i].getName());
// getter method
out.printin("public ");
if (attrInfos[i].isFragment()) {
out.print("javax.servlet.jsp.tagext.JspFragment ");
} else {
out.print(JspUtil.toJavaSourceType(attrInfos[i].getTypeName()));
out.print(" ");
}
out.print(toGetterMethod(attrInfos[i].getName()));
out.println(" {");
out.pushIndent();
out.printin("return this.");
out.print(javaName);
out.println(";");
out.popIndent();
out.printil("}");
out.println();
// setter method
out.printin("public void ");
out.print(toSetterMethodName(attrInfos[i].getName()));
if (attrInfos[i].isFragment()) {
out.print("(javax.servlet.jsp.tagext.JspFragment ");
} else {
out.print("(");
out.print(JspUtil.toJavaSourceType(attrInfos[i].getTypeName()));
out.print(" ");
}
out.print(javaName);
out.println(") {");
out.pushIndent();
out.printin("this.");
out.print(javaName);
out.print(" = ");
out.print(javaName);
out.println(";");
if (ctxt.isTagFile()) {
// Tag files should also set jspContext attributes
out.printin("jspContext.setAttribute(\"");
out.print(attrInfos[i].getName());
out.print("\", ");
out.print(javaName);
out.println(");");
}
out.popIndent();
out.printil("}");
out.println();
}
}
示例4: checkNamedAttributes
import javax.servlet.jsp.tagext.TagInfo; //导入方法依赖的package包/类
private void checkNamedAttributes(Node.CustomTag n,
Node.JspAttribute[] jspAttrs, int start,
Hashtable<String, Object> 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,
tldAttrs[j], 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, null,
true);
} else {
err.jspError(n, "jsp.error.bad_attribute",
na.getName(), n.getLocalName());
}
}
}
}
示例5: generateTagHandlerAttributes
import javax.servlet.jsp.tagext.TagInfo; //导入方法依赖的package包/类
/**
* Generates declarations for tag handler attributes, and defines the getter
* and setter methods for each.
*/
private void generateTagHandlerAttributes(TagInfo tagInfo)
throws JasperException {
if (tagInfo.hasDynamicAttributes()) {
out.printil("private java.util.HashMap _jspx_dynamic_attrs = new java.util.HashMap();");
}
// Declare attributes
TagAttributeInfo[] attrInfos = tagInfo.getAttributes();
for (int i = 0; i < attrInfos.length; i++) {
out.printin("private ");
if (attrInfos[i].isFragment()) {
out.print("javax.servlet.jsp.tagext.JspFragment ");
} else {
out.print(JspUtil.toJavaSourceType(attrInfos[i].getTypeName()));
out.print(" ");
}
out.print(attrInfos[i].getName());
out.println(";");
}
out.println();
// Define attribute getter and setter methods
if (attrInfos != null) {
for (int i = 0; i < attrInfos.length; i++) {
// getter method
out.printin("public ");
if (attrInfos[i].isFragment()) {
out.print("javax.servlet.jsp.tagext.JspFragment ");
} else {
out.print(JspUtil.toJavaSourceType(attrInfos[i]
.getTypeName()));
out.print(" ");
}
out.print(toGetterMethod(attrInfos[i].getName()));
out.println(" {");
out.pushIndent();
out.printin("return this.");
out.print(attrInfos[i].getName());
out.println(";");
out.popIndent();
out.printil("}");
out.println();
// setter method
out.printin("public void ");
out.print(toSetterMethodName(attrInfos[i].getName()));
if (attrInfos[i].isFragment()) {
out.print("(javax.servlet.jsp.tagext.JspFragment ");
} else {
out.print("(");
out.print(JspUtil.toJavaSourceType(attrInfos[i]
.getTypeName()));
out.print(" ");
}
out.print(attrInfos[i].getName());
out.println(") {");
out.pushIndent();
out.printin("this.");
out.print(attrInfos[i].getName());
out.print(" = ");
out.print(attrInfos[i].getName());
out.println(";");
if (ctxt.isTagFile()) {
// Tag files should also set jspContext attributes
out.printin("jspContext.setAttribute(\"");
out.print(attrInfos[i].getName());
out.print("\", ");
out.print(attrInfos[i].getName());
out.println(");");
}
out.popIndent();
out.printil("}");
out.println();
}
}
}
示例6: visit
import javax.servlet.jsp.tagext.TagInfo; //导入方法依赖的package包/类
@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());
}
/*
* The bodycontent 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<String, Object> tagDataAttrs = new Hashtable<String, Object>(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);
n.setJspAttributes(jspAttrs);
visitBody(n);
}
示例7: checkNamedAttributes
import javax.servlet.jsp.tagext.TagInfo; //导入方法依赖的package包/类
private void checkNamedAttributes(Node.CustomTag n, Node.JspAttribute[] jspAttrs, int start,
Hashtable<String, Object> 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, tldAttrs[j], 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, null, true);
} else {
err.jspError(n, "jsp.error.bad_attribute", na.getName(), n.getLocalName());
}
}
}
}
示例8: getAttributeBodyType
import javax.servlet.jsp.tagext.TagInfo; //导入方法依赖的package包/类
/**
* Determine the body type of <jsp:attribute> from the enclosing node
*/
private String getAttributeBodyType(Node n, String name) {
if (n instanceof Node.CustomTag) {
TagInfo tagInfo = ((Node.CustomTag) n).getTagInfo();
TagAttributeInfo[] tldAttrs = tagInfo.getAttributes();
for (int i = 0; i < tldAttrs.length; i++) {
if (name.equals(tldAttrs[i].getName())) {
if (tldAttrs[i].isFragment()) {
return TagInfo.BODY_CONTENT_SCRIPTLESS;
}
if (tldAttrs[i].canBeRequestTime()) {
return TagInfo.BODY_CONTENT_JSP;
}
}
}
if (tagInfo.hasDynamicAttributes()) {
return TagInfo.BODY_CONTENT_JSP;
}
} else if (n instanceof Node.IncludeAction) {
if ("page".equals(name)) {
return TagInfo.BODY_CONTENT_JSP;
}
} else if (n instanceof Node.ForwardAction) {
if ("page".equals(name)) {
return TagInfo.BODY_CONTENT_JSP;
}
} else if (n instanceof Node.SetProperty) {
if ("value".equals(name)) {
return TagInfo.BODY_CONTENT_JSP;
}
} else if (n instanceof Node.UseBean) {
if ("beanName".equals(name)) {
return TagInfo.BODY_CONTENT_JSP;
}
} else if (n instanceof Node.PlugIn) {
if ("width".equals(name) || "height".equals(name)) {
return TagInfo.BODY_CONTENT_JSP;
}
} else if (n instanceof Node.ParamAction) {
if ("value".equals(name)) {
return TagInfo.BODY_CONTENT_JSP;
}
} else if (n instanceof Node.JspElement) {
return TagInfo.BODY_CONTENT_JSP;
}
return JAVAX_BODY_CONTENT_TEMPLATE_TEXT;
}
示例9: generateTagHandlerAttributes
import javax.servlet.jsp.tagext.TagInfo; //导入方法依赖的package包/类
/**
* Generates declarations for tag handler attributes, and defines the getter
* and setter methods for each.
*/
private void generateTagHandlerAttributes(TagInfo tagInfo) {
if (tagInfo.hasDynamicAttributes()) {
out.printil("private java.util.HashMap _jspx_dynamic_attrs = new java.util.HashMap();");
}
// Declare attributes
TagAttributeInfo[] attrInfos = tagInfo.getAttributes();
for (int i = 0; i < attrInfos.length; i++) {
out.printin("private ");
if (attrInfos[i].isFragment()) {
out.print("javax.servlet.jsp.tagext.JspFragment ");
} else {
out.print(JspUtil.toJavaSourceType(attrInfos[i].getTypeName()));
out.print(" ");
}
out.print(JspUtil.makeJavaIdentifierForAttribute(attrInfos[i].getName()));
out.println(";");
}
out.println();
// Define attribute getter and setter methods
for (int i = 0; i < attrInfos.length; i++) {
String javaName = JspUtil.makeJavaIdentifierForAttribute(attrInfos[i].getName());
// getter method
out.printin("public ");
if (attrInfos[i].isFragment()) {
out.print("javax.servlet.jsp.tagext.JspFragment ");
} else {
out.print(JspUtil.toJavaSourceType(attrInfos[i].getTypeName()));
out.print(" ");
}
out.print(toGetterMethod(attrInfos[i].getName()));
out.println(" {");
out.pushIndent();
out.printin("return this.");
out.print(javaName);
out.println(";");
out.popIndent();
out.printil("}");
out.println();
// setter method
out.printin("public void ");
out.print(toSetterMethodName(attrInfos[i].getName()));
if (attrInfos[i].isFragment()) {
out.print("(javax.servlet.jsp.tagext.JspFragment ");
} else {
out.print("(");
out.print(JspUtil.toJavaSourceType(attrInfos[i].getTypeName()));
out.print(" ");
}
out.print(javaName);
out.println(") {");
out.pushIndent();
out.printin("this.");
out.print(javaName);
out.print(" = ");
out.print(javaName);
out.println(";");
if (ctxt.isTagFile()) {
// Tag files should also set jspContext attributes
out.printin("jspContext.setAttribute(\"");
out.print(attrInfos[i].getName());
out.print("\", ");
out.print(javaName);
out.println(");");
}
out.popIndent();
out.printil("}");
out.println();
}
}