• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to pass collection as an attribute to Tag File  RSS feed

 
Allan Wang
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(Env: Tomcat 5.5.9)
I want to pass the collection object which is saved in the request to Tag file via attribute. Something like this:
jsp:
<tag1:showBook bookList="${myBookList}" />

tag file (tag1.tag)
<%@ attribute name="bookList" type="java.util.Collection" %>

But it throws the exception:
org.apache.jasper.JasperException: jsp.error.beans.property.conversionorg.apache.jasper.runtime.JspRuntimeLibrary.getValueFromPropertyEditorManager(JspRuntimeLibrary.java:885)

I looked into translated jsp code. The EL was not translated. "${myBookList}" is only taken as a String.

Please shed some lights on it. Thanks in advance.
allan
[ May 24, 2005: Message edited by: Allan Wang ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The EL was not translated.


Is EL translated elsewhere on the page?
 
Allan Wang
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. EL was translated correctly elsewhere on the page.

Now I think the question is whether we can pass a collection as an attribute to custom Tag file. In the other word, can I specify 'type="java.util.Collection' in the declaration of attribute in the tag file? It looks to me Tomcat doesn't support this type.
 
Allan Wang
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear. Finally I figured out the problem is from the version of J2EE and JSTL. My IDE automatically specified the version of Servlet to 2.2 and I've been mistakenly using JSTL 1.0 (my declare was <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>, it should be <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> . After I corrected these version issues, everything works perfectly.


[ May 25, 2005: Message edited by: Allan Wang ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!