jeff luo wrote:
>
> Hi, I want to create a tag that can declare a script
> variable in the jsp page, I use the tag extraInfo
> class to declare the variable, it work fine when I
> know how many variable I want to declare in the jsp
> page. But I have a problem need to solve, the
> variable number defined in the extratInfo class
> (VariableInfo[] ) is fixed, but I may call the tag
> many times in the jsp page(dynamic), how can I solve
> this problem? Can I define a dynamic list in the
> ExtraInfo class for the tag? thanks!
Typically you solve this by letting the page author specify
a unique variable name for each occurrence of the tag in
the page, following the same model as the <jsp:useBean>
action, e.g.:
<foo:myAction id="aUniqueName" />
with a TagExtraInfo class that looks something like
this:
public class MyActionTEI extends TagExtraInfo {
public VariableInfo[] getVariableInfo(TagData data) {
VariableInfo vi =
new VariableInfo(data.getAttributeString("id"),
"java.lang.String",
true,
VariableInfo.AT_END);
return vi;
}
}
<plug>
I describe this in much more detail in my JSP book:
<http://TheJSPBook.com/>
</plug>
Hans
--
Hans Bergsten [EMAIL PROTECTED]
Gefion Software http://www.gefionsoftware.com
Author of JavaServer Pages (O'Reilly), http://TheJSPBook.com
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets