java - Using varargs in a Tag Library Descriptor -
is possible have tld map following function:
public static <t> t[] toarray(t... stuff) { return stuff; }
so can do:
<c:foreach items="${my:toarray('a', 'b', 'c')}"...
i tried following <function-signature>
s
java.lang.object toarray( java.lang.object... ) java.lang.object[] toarray( java.lang.object[] )
and others nothing seems work.
unfortunately that's not possible. el resolver interprets commas in function separate arguments without checking if there methods taking varargs. best bet using jstl fn:split()
instead.
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> ... <c:foreach items="${fn:split('a,b,c', ',')}" var="item"> ${item}<br/> </c:foreach>
it have been nice feature in el however, although implementing pretty complex.
Comments
Post a Comment