Help! A co-worker of mine is wrestling with how to handle indexed properties
using custom tags. Below is a summary of the problem, and possible
solutions we've considered. Anyone have any elegant solution, or
suggestions from experience?
Thanks,
Steve
=========
I am looking for an elegant way to expose an indexed property as an
attribute (or attributes) of a custom tag.
I have not found an elegant way to do this, please let me know if you have
an idea that is not covered below ..
(1) Implement multiple attributes on the tag:
<prefix:tag myProp0="value0" myProp1="value1" ... myPropX="valueX"/>.
Obviously, this has a hard coded upper limit which is not desirable.
(2) Only accept a String:
<prefix:tag myProp="value0,value1,value2"/>
This is sometimes desirable, but the values can themselves be made up of
multiple elements, and it gets real complex real quick.
(3) Only accept a collection:
<%Collection myCollection = new Collection(...)%>
<prefix:tag myProp="<%=myCollection%>">
However, I don't want my users to have to use any Java.
Having the value defined outside of the tag is also not desirable.
4. A variation of the above, without Java:
<prefix:collectionTag id="myCollection">
...
</collectionTag>
<prefix:tag myProp="$myCollection">
My concern here is that "$" is not standard, and when the standard tag lib
is released, users might expect to be able to use other types of expressions
in the value (which will not be supported).
5. Use an nested tag to specify the values, e.g.
<prefix:tag myProp="$myCollection">
<prefix:myProp index="0" myProp="value0">
<prefix:myProp index="1" myProp="value1">
<prefix:tag myProp="$myCollection">
This is probably the best solution, but I have a large number of attributes,
and don't want to create a seperate tag for each or split the property
setting between attributes and nested tags.
Any other ideas?
Thanks in advance,
Dave Burford
===========================================================================
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