Hi,
I am trying to figure out the purpose of the TagExtraInfo class and exactly
when a TagExtraInfo class needs to be developed for a custom tag.
The JSP Spec states:
"Since the logic that decides whether an action instance will define a
scripting variable may
be quite complex, this information is not encoded in the Tag Library
Descriptor directly;
rather, the name of a TagExtraInfo class is given in the TLD and the
getVariableInfo method is used at translation time to obtain information on
each
variable that will be created at request time when this action is executed.
The method is
passed a TagData instance that contains the translation-time attribute
values."
1) Does this mean that *anytime* a tag creates a scripting variable (e.g.
via a call to pageContext.setAttribute()), a TagExtraInfo class needs to be
developed?
2) If I develop a custom tag, I can control the scoping of various scripting
variables by using the various forms of pageContext.setAttribute() and
pageContext.removeAttribute() methods in the appropriate tag methods (e.g.
doStartTag(), doEndTag(), doAfterBody(), etc). If this is true, what is the
purpose of the TagExtraInfo class?
3) What does a "typical" TagExtraInfo class look like (e.g.
getVariableInfo())? The JSP spec shows no examples. Is the creation of a
VariableInfo entry dependent upon the current state of the TagData instance?
Here is my guess as to how the TagExtraInfo class might look for the
following tag, does it make sense?:
<x:bar id=�mybar� att1=�...� att2=�...� att3=�...� />
public class FooBarTagExtraInfo extends TagExtraInfo
{
public VariableInfo[] getVariableInfo(TagData data)
// Get the value of the object we are trying to scope from the tag
instance.
VariableInfo[] varInfoArray = null;
String id = data.getId();
// Only create a VariableInfo entry if the value has been set.
if (id != null)
{
varInfoArray = new VariableInfo[1];
// Create a VariableInfo object which defines that
// name, type, declare, and scope of the "id" variable.
// Scope values can be NESTED, AT_BEGIN, or AT_END VariableInfo
varInfo = new VariableInfo("id", "java.lang.String", true,
NESTED);
}
else
// This returns an empty array
varInfoArray = super.getVariableInfo(data);
}
return varInfoArray;
}
}
Thanks,
Kevin Jacobson
[EMAIL PROTECTED]
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html