You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Yan, Charlene" <Ch...@thomsonlearning.com> on 2003/01/21 19:55:34 UTC
RE: ClassCastException using type attribute with iterate tag
Does this work?
<logic:iterate name="problemArray" id="currentProb" scope="request">
<bean:write name="currentProb" property="problemName"/>
</logic:iterate>
If yes, make changes as the following:
<logic:iterate name="problemArray" id="currentProb" scope="request">
<bean:write name="currentProb" property="problemName"/>
<html:radio name="currentProb" property="name" />
</logic:iterate>
Let me know if it works.
Charlene
-----Original Message-----
From: Jeremy Cavagnolo [mailto:jeremy@paradoxcomponents.com]
Sent: Tuesday, January 21, 2003 2:41 PM
To: struts-user@jakarta.apache.org
Subject: ClassCastException using type attribute with iterate tag
I wasn't exactly clear with what I am trying to do. Here is what I really
want to do:
<logic:iterate name="problemArray" id="currentProb" scope="request">
<bean:write name="currentProb" property="problemName"/>
<html:radio property="problem" value="<%= currentProb.getName() %>">
</logic:iterate>
but when I add type="org.alf.msq.data.Problem" to my iterate tag, I get
the ClassCastException. Further, no matter how I try to cast an element
of the problemArray to org.alf.msq.data, whether it is inside or outside
the iterate tag, I get the Exception. I even did the following:
System.out.println(problemArray.get(0).getClass().getName());
and it returned org.alf.msq.data.Problem!
Any insight is much appreciated. The relevant stack trace from the log
follows.
Thanks,
Jeremy
jsp: init
ApplicationDispatcher[/MSQ] Servlet.service() for servlet jsp threw
exception org.apache.jasper.JasperException
at org.apache.jasper.servlet.JspServletWrapper.service(Unknown Source)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(Unknown Source)
at org.apache.jasper.servlet.JspServlet.service(Unknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
...
----- Root Cause -----
java.lang.ClassCastException
at org.apache.jsp.probSelect_jsp._jspService(probSelect_jsp.java:161)
at org.apache.jasper.runtime.HttpJspBase.service(Unknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
at org.apache.jasper.servlet.JspServletWrapper.service(Unknown Source)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(Unknown Source)
at org.apache.jasper.servlet.JspServlet.service(Unknown Source)
...
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: ClassCastException using type attribute with iterate tag
Posted by Kris Schneider <kr...@dotech.com>.
Not sure about the exception, but as of 1.1, you can write your loop like this:
<logic:iterate name="problemArray" id="currentProb" scope="request">
<bean:write name="currentProb" property="problemName"/>
<html:radio property="problem" idName="currentProb" value="name"/>
</logic:iterate>
See:
http://jakarta.apache.org/struts/userGuide/struts-html.html#radio
Also a clarification that the "property" attribute of the <html:radio> tag does
*not* need to be linked to the form bean. That's just the default. You can also
provide a "name" attribute to link to another bean.
Quoting Jeremy Cavagnolo <je...@paradoxcomponents.com>:
> Charlene:
>
> Thanks for the input. However, it didn't work. The html:radio tab
> requires the value tag, so it knows what value to assign the problem
> variable in the corresponding form bean (I got a compilation error). This
> is the whole problem, since I need to get this value from my
> org.alf.msq.data.Problem object.
>
> Further, it is my understanding that the property attribute of the
> html:radio tag must point towards the appropriate parameter in the form
> bean.
>
> I suspect that for some reason the jsp compiler can't find my
> Problem.class file, which is why it can't appropriately cast this object.
> Also, since I can't correctly cast the object under any circumstances
> within the jsp, I don't think the problem is with the iterate tag.
>
> Thanks for your input, though. And if you have any ideas, I would
> appreciate them.
>
> thanks,
>
> Jeremy
>
> On Tue, 21 Jan 2003, Yan, Charlene wrote:
>
> > Does this work?
> > <logic:iterate name="problemArray" id="currentProb" scope="request">
> > <bean:write name="currentProb" property="problemName"/>
> > </logic:iterate>
> >
> > If yes, make changes as the following:
> > <logic:iterate name="problemArray" id="currentProb" scope="request">
> > <bean:write name="currentProb" property="problemName"/>
> > <html:radio name="currentProb" property="name" />
> > </logic:iterate>
> >
> > Let me know if it works.
> >
> > Charlene
> > -----Original Message-----
> > From: Jeremy Cavagnolo [mailto:jeremy@paradoxcomponents.com]
> > Sent: Tuesday, January 21, 2003 2:41 PM
> > To: struts-user@jakarta.apache.org
> > Subject: ClassCastException using type attribute with iterate tag
> >
> >
> > I wasn't exactly clear with what I am trying to do. Here is what I really
>
> > want to do:
> >
> > <logic:iterate name="problemArray" id="currentProb" scope="request">
> > <bean:write name="currentProb" property="problemName"/>
> > <html:radio property="problem" value="<%= currentProb.getName() %>">
> > </logic:iterate>
> >
> > but when I add type="org.alf.msq.data.Problem" to my iterate tag, I get
> > the ClassCastException. Further, no matter how I try to cast an element
> > of the problemArray to org.alf.msq.data, whether it is inside or outside
> > the iterate tag, I get the Exception. I even did the following:
> >
> > System.out.println(problemArray.get(0).getClass().getName());
> >
> > and it returned org.alf.msq.data.Problem!
> >
> > Any insight is much appreciated. The relevant stack trace from the log
> > follows.
> >
> > Thanks,
> >
> > Jeremy
> >
> > jsp: init
> > ApplicationDispatcher[/MSQ] Servlet.service() for servlet jsp threw
> > exception org.apache.jasper.JasperException
> > at org.apache.jasper.servlet.JspServletWrapper.service(Unknown
> Source)
> > at org.apache.jasper.servlet.JspServlet.serviceJspFile(Unknown
> Source)
> > at org.apache.jasper.servlet.JspServlet.service(Unknown Source)
> > at javax.servlet.http.HttpServlet.service(HttpServlet.java)
> >
> > ...
> >
> >
> > ----- Root Cause -----
> > java.lang.ClassCastException
> > at org.apache.jsp.probSelect_jsp._jspService(probSelect_jsp.java:161)
> > at org.apache.jasper.runtime.HttpJspBase.service(Unknown Source)
> > at javax.servlet.http.HttpServlet.service(HttpServlet.java)
> > at org.apache.jasper.servlet.JspServletWrapper.service(Unknown Source)
> > at org.apache.jasper.servlet.JspServlet.serviceJspFile(Unknown Source)
> > at org.apache.jasper.servlet.JspServlet.service(Unknown Source)
> >
> > ...
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
--
Kris Schneider <ma...@dotech.com>
D.O.Tech <http://www.dotech.com/>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: ClassCastException using type attribute with iterate tag
Posted by Jeremy Cavagnolo <je...@paradoxcomponents.com>.
Charlene:
Thanks for the input. However, it didn't work. The html:radio tab
requires the value tag, so it knows what value to assign the problem
variable in the corresponding form bean (I got a compilation error). This
is the whole problem, since I need to get this value from my
org.alf.msq.data.Problem object.
Further, it is my understanding that the property attribute of the
html:radio tag must point towards the appropriate parameter in the form
bean.
I suspect that for some reason the jsp compiler can't find my
Problem.class file, which is why it can't appropriately cast this object.
Also, since I can't correctly cast the object under any circumstances
within the jsp, I don't think the problem is with the iterate tag.
Thanks for your input, though. And if you have any ideas, I would
appreciate them.
thanks,
Jeremy
On Tue, 21 Jan 2003, Yan, Charlene wrote:
> Does this work?
> <logic:iterate name="problemArray" id="currentProb" scope="request">
> <bean:write name="currentProb" property="problemName"/>
> </logic:iterate>
>
> If yes, make changes as the following:
> <logic:iterate name="problemArray" id="currentProb" scope="request">
> <bean:write name="currentProb" property="problemName"/>
> <html:radio name="currentProb" property="name" />
> </logic:iterate>
>
> Let me know if it works.
>
> Charlene
> -----Original Message-----
> From: Jeremy Cavagnolo [mailto:jeremy@paradoxcomponents.com]
> Sent: Tuesday, January 21, 2003 2:41 PM
> To: struts-user@jakarta.apache.org
> Subject: ClassCastException using type attribute with iterate tag
>
>
> I wasn't exactly clear with what I am trying to do. Here is what I really
> want to do:
>
> <logic:iterate name="problemArray" id="currentProb" scope="request">
> <bean:write name="currentProb" property="problemName"/>
> <html:radio property="problem" value="<%= currentProb.getName() %>">
> </logic:iterate>
>
> but when I add type="org.alf.msq.data.Problem" to my iterate tag, I get
> the ClassCastException. Further, no matter how I try to cast an element
> of the problemArray to org.alf.msq.data, whether it is inside or outside
> the iterate tag, I get the Exception. I even did the following:
>
> System.out.println(problemArray.get(0).getClass().getName());
>
> and it returned org.alf.msq.data.Problem!
>
> Any insight is much appreciated. The relevant stack trace from the log
> follows.
>
> Thanks,
>
> Jeremy
>
> jsp: init
> ApplicationDispatcher[/MSQ] Servlet.service() for servlet jsp threw
> exception org.apache.jasper.JasperException
> at org.apache.jasper.servlet.JspServletWrapper.service(Unknown Source)
> at org.apache.jasper.servlet.JspServlet.serviceJspFile(Unknown Source)
> at org.apache.jasper.servlet.JspServlet.service(Unknown Source)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java)
>
> ...
>
>
> ----- Root Cause -----
> java.lang.ClassCastException
> at org.apache.jsp.probSelect_jsp._jspService(probSelect_jsp.java:161)
> at org.apache.jasper.runtime.HttpJspBase.service(Unknown Source)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java)
> at org.apache.jasper.servlet.JspServletWrapper.service(Unknown Source)
> at org.apache.jasper.servlet.JspServlet.serviceJspFile(Unknown Source)
> at org.apache.jasper.servlet.JspServlet.service(Unknown Source)
>
> ...
>
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>