• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing Objects to a Tag File

 
Frederic Filiatrault
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

Think I'm confusing few things. Can you help me out ?

It is possible to configure attributes for tag Files, like this example :

-------------------------------------------------------------------
(Demo.tag)
-------------------------------------------------------------------
<%@ tag body-content="scriptless"%>
<%@ attribute name="test" required="true" type="java.util.Vector"%>
There is : <%=test.size()%> element(s).
-------------------------------------------------------------------

-------------------------------------------------------------------
(Demo.jsp)
-------------------------------------------------------------------
<%@ taglib tagdir="/WEB-INF/tags" prefix="t"%>
<!Vector list = new Vector();%>
<t emo test="list"/>
-------------------------------------------------------------------

There is the error. Any idea?

org.apache.jasper.JasperException: jsp.error.beans.property.conversion
org.apache.jasper.runtime.JspRuntimeLibrary.getValueFromPropertyEditorManager(JspRuntimeLibrary.java:885)
org.apache.jsp.Demo_jsp._jspx_meth_t_Demo_0(Demo_jsp.java:74)
org.apache.jsp.Demo_jsp._jspService(Demo_jsp.java:51)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:298)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
 
Frederic Filiatrault
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi again,

I found it out !

<temo test="<%=list%>"/>

Ok. Now, why ?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[Aside: be sure to click the 'disable smilies' checkbox when posting code]

<t:demo test="list"/>


In the above, "list" is a string.

<t:demo test="<%=list%>"/>


In this, "list" is a referenc to the class-level scripting variable (ugh!) that you created.

You get the error in the first case because a String cannot be converted to a Vector.

[ July 22, 2004: Message edited by: Bear Bibeault ]
[ July 22, 2004: Message edited by: Bear Bibeault ]
 
Frederic Filiatrault
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thk !
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic