Re: iterating over a collection
Use 'name="allTheCoins"' instead of 'collection="allTheCoins"'. -- Martin Cooper - Original Message - From: "Anish Acharya" <[EMAIL PROTECTED]> To: "Struts Help (E-mail)" <[EMAIL PROTECTED]> Sent: Wednesday, September 19, 2001 7:27 AM Subject: iterating over a collection > Hello everyone. Just wondering if anyone can spot the error in this code: > > <% Vector allTheCoins = (Vector)(application.getAttribute("allCoins")); > %> > > > > > > > > > > > I have traced it to the logic tag -- the vector does initialize properly. > All of the elements > of the vector are strings. Struts gives me an error claming it "can not > convert Java.lang.String > into Java.lang.object". > > I've pulled out all my hair trying to figure this one out -- any help would > be appreciated. > > Thanks in advance, > > -Anish
RE: iterating over a collection
Thanks for the response. Unfortunetly specifying the class as "java.lang.String" (since that is what my vector contains) has no effect. Any other ideas? Thanks, -Anish -Original Message- From: Princeton Lau [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 19, 2001 10:49 AM To: '[EMAIL PROTECTED]' Subject: RE: iterating over a collection Anish, Try specifying the type property of the logic tag. >From the Jakarta Struts site... "Fully qualified Java class name of the element to be exposed through the JSP bean named from the id attribute. If not present, no type conversions will be performed. NOTE: The actual elements of the collection must be assignment-compatible with this class, or a request time ClassCastException will occur." So your logic tag would look like: Princeton -Original Message- From: Anish Acharya [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 19, 2001 8:27 AM To: Struts Help (E-mail) Subject: iterating over a collection Hello everyone. Just wondering if anyone can spot the error in this code: <% Vector allTheCoins = (Vector)(application.getAttribute("allCoins")); %> I have traced it to the logic tag -- the vector does initialize properly. All of the elements of the vector are strings. Struts gives me an error claming it "can not convert Java.lang.String into Java.lang.object". I've pulled out all my hair trying to figure this one out -- any help would be appreciated. Thanks in advance, -Anish
Re: iterating over a collection
The docs say it has to be a run-time expression. Without the <%= ... %> then its just a plain ol' String. Erik - Original Message - From: "Anish Acharya" <[EMAIL PROTECTED]> To: "Struts Help (E-mail)" <[EMAIL PROTECTED]> Sent: Wednesday, September 19, 2001 7:27 AM Subject: iterating over a collection > Hello everyone. Just wondering if anyone can spot the error in this code: > > <% Vector allTheCoins = (Vector)(application.getAttribute("allCoins")); > %> > > > > > > > > > > > I have traced it to the logic tag -- the vector does initialize properly. > All of the elements > of the vector are strings. Struts gives me an error claming it "can not > convert Java.lang.String > into Java.lang.object". > > I've pulled out all my hair trying to figure this one out -- any help would > be appreciated. > > Thanks in advance, > > -Anish >
RE: iterating over a collection
Anish, Try specifying the type property of the logic tag. >From the Jakarta Struts site... "Fully qualified Java class name of the element to be exposed through the JSP bean named from the id attribute. If not present, no type conversions will be performed. NOTE: The actual elements of the collection must be assignment-compatible with this class, or a request time ClassCastException will occur." So your logic tag would look like: Princeton -Original Message- From: Anish Acharya [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 19, 2001 8:27 AM To: Struts Help (E-mail) Subject: iterating over a collection Hello everyone. Just wondering if anyone can spot the error in this code: <% Vector allTheCoins = (Vector)(application.getAttribute("allCoins")); %> I have traced it to the logic tag -- the vector does initialize properly. All of the elements of the vector are strings. Struts gives me an error claming it "can not convert Java.lang.String into Java.lang.object". I've pulled out all my hair trying to figure this one out -- any help would be appreciated. Thanks in advance, -Anish