struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Henrikson" <kevin.henrik...@openwave.com>
Subject RE: How to avoid a scriplet and make this cleaner?
Date Tue, 02 Jul 2002 02:46:05 GMT
Try to cast the value to a string.

<html:checkbox property="carID" value="<%=(String)((CarBean)element).getId() %>"
/>

Also you might want to check out multibox... Like this:

<logic:iterate id="element" name="cars">
     <html:multibox property="carID">
       <bean:write name="element" property="id" />
     </html:multibox>
</logic:iterate>


-kevin

> -----Original Message-----
> From: Rick Reumann [mailto:maillist@reumann.net]
> Sent: Monday, July 01, 2002 7:22 PM
> To: Struts Users Mailing List
> Subject: How to avoid a scriplet and make this cleaner?
>
>
> For this example I have an ArrayList of "cars" (which are CarBeans
> with String carName, int id ). I want to iterate over this ArrayList
> and set up each car name with a checbox next to it with the id as the
> value. My FormBean has the property String[] carID to get the cars
> selected.
>
> The problem is I can't seem to avoid using a scriplet and can't seem
> to use the checkbox tag to set up the following:
>
> <logic:iterate id="element" name="cars" >
>   <TR>
>     <TD><bean:write name="element" property="carName"/></TD>
>     <TD>
>       <input type="checkbox" name="carID" value="<%=
> ((CarBean)element).getId() %>"/>
>     </TD>
>  </TR>
> </logic:iterate>
>
> I want to avoid having to use the scriplet for the value above. I also
> get errors when I try to use the tag for the checkbox with the
> scriplet:
>
> <html:checkbox property="carID" value="<%= ((CarBean)element).getId() %>" />
>
>
> Any ideas how I can make the above code cleaner and/or get the
> checkbox tag to work?
>
> TIA
>
> --
>
> Rick
>
> mailto:maillist@reumann.net
>
>
> --
> To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>
>
>
>




--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message