Search code examples
jspspring-mvceljsp-tagsjboss-4.0.x

Spring select tag in jsp custom tag


I'm trying to accomplish the following in a JSP tag:

select.tag

<%@ attribute name="id" required="true" %>
<%@ attribute name="path" required="true" %>
<%@ attribute name="items" required="true" %>
<%@ attribute name="itemLabel" required="false" %>
<%@ attribute name="itemValue" required="false" %>

<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<form:select path="${path}" id="${id}">
    <form:options items="${items}" itemLabel="${itemLabel}" itemValue="${itemValue}"/>
</form:select>

Usage: (mycollectionattribute is defined with @ModelAttribute("mycollectionattribute"))

<tags:select items="${mycollectionattribute}" id="id" path="mybean.selectvalue" itemLabel="label" itemValue="id"/>

However, I can't figure out how to correctly map the collection of items from the calling page to this tag. EL does not seem to be evaluated and is sent as a string, causing the following error:

javax.servlet.ServletException: Type [java.lang.String] is not valid for option items

I'm using a pretty old version of JSTL, the one bundled with JBoss 4.04GA, might this be the problem? I'm not sure when EL expressions are evaluated exactly, ${x} directly in markup doesn't evaluate for example, it only works in special tags. Might an upgrade solve this problem? And if so, how hard is it to use your own JSTL lib instead of the one bundled with JBoss?


Solution

  • Solved.

    Was using mismatching servlet versions (2.5 specified, but JBoss 4 uses 2.4), both as dependency and in in web.xml. So EL wasn't working like it should.