Thanks for trying to help Kevin..comments below...

On Monday, July 1, 2002, 10:46:05 PM, Kevin Henrikson wrote:

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

   The above wouldn't work since I can't cast a primitive int to a
   String like that, but even
   <%= Integer.parseInt( ((CarBean)element).getId() ) %>
   wouldn't work. It's only inside of a tag that I have this problem
   using <%= %> syntax or even <% %> which doesn't work at all. Oh
   well, with the below I'm fine...

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

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

    Thanks Kevin! That multibox works perfectly. No need to use the
    scriplet above when using the multibox like:

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

    </END RICK COMMENTS>

>> -----Original Message-----
>> From: Rick Reumann [mailto:[EMAIL PROTECTED]]
>> 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


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to