jsp - Taglib in Java: tag with array parameter -
how can define tag receives array parameter?
thanks
jstl it, , can too.
i happen have el function example handy, , i'll paste portion of c:foreach definition give idea:
you pass delimited string, if want collection or array, can use this:
<function> <name>join</name> <function-class>mypackage.functions</function-class> <function-signature>string join(java.lang.object, java.lang.string)</function-signature> </function>
and
/** * jstl's fn:join works string[]. 1 more general. * * usage: ${nc:join(values, ", ")} */ public static string join(object values, string seperator) { if (values == null) return null; if (values instanceof collection<?>) return stringutils.join((collection<?>) values, seperator); else if (values instanceof object[]) return stringutils.join((object[]) values, seperator); else return values.tostring(); }
obviously, instead of object
input can use array if don't want handle collections well.
here c:foreach definition:
<tag> <description> basic iteration tag, accepting many different collection types , supporting subsetting , other functionality </description> <name>foreach</name> <tag-class>org.apache.taglibs.standard.tag.rt.core.foreachtag</tag-class> <tei-class>org.apache.taglibs.standard.tei.foreachtei</tei-class> <body-content>jsp</body-content> <attribute> <description> collection of items iterate over. </description> <name>items</name> <required>false</required> <rtexprvalue>true</rtexprvalue> <type>java.lang.object</type> </attribute> ...
Comments
Post a Comment