You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by "Barnett, Brian W." <bb...@scholarinc.com> on 2004/05/28 01:04:09 UTC
calling a method in c:if tag
I have a List object as a request scoped variable and I want to call a
method on it as the test of a c:if statement. Is this a "no no"? All the
examples I see for c:if use bean objects in the test. I've tried using the
List object with a number of different syntaxes, but I get "error occurred
while evaluating custom action attribute 'test'" errors.
Tried:
<c:if test="${!empty schoolList}">
<c:if test="${!empty requestScope.schoolList}">
<c:if test="${!empty requestScope.schoolList[0]}">
What I really want to do is something like this:
<c:if test="${schoolList.size() > 0}">.
When I try it, I get this error:
[ServletException in:/WEB-INF/jsp/SchoolList.jsp]
javax.servlet.jsp.JspException: An error occurred while evaluating custom
action attribute "test" with value "${schoolList.size > 0}": The "."
operator was supplied with an index value of type "java.lang.String" to be
applied to a List or array, but that value cannot be converted to an
integer. (null)'
Re: calling a method in c:if tag
Posted by Felipe Leme <ja...@felipeal.net>.
On Thu, 2004-05-27 at 20:04, Barnett, Brian W. wrote:
> I have a List object as a request scoped variable and I want to call a
> method on it as the test of a c:if statement. Is this a "no no"?
No, this is a "no yes" :-): no, you can't do it on JSTL 1.0, but yes,
you can on JSTL 1.1, using EL functions.
> What I really want to do is something like this:
>
> <c:if test="${schoolList.size() > 0}">.
On JSTL 1.1, you could use:
<c:if test="${fn:length(schoolList) > 0}">
BTW, there is a similar example on Sun's Web Service tutorial:
http://java.sun.com/webservices/docs/1.3/tutorial/doc/IntroIWA5.html
Felipe
---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org