I have the below code in my JSP. The problem is while i run this code, i get the below exception:
The method setValue(String) in the type OptionTag is not applicable for the arguments (Object).
Does anyone have an idea?
<html:select property="selectedServices" name="specificStoreForm" multiple="true" styleClass="services">
<logic:iterate id="service" name="services" property="selectedServices">
<bean:define id="textVal" name="service" property="value" toScope="request"/>
<html:option value="<%=textVal%>">
<bean:write name="service" property="label"/>
</html:option>
</logic:iterate>
</html:select>
Judging from the documentation the result from the <bean:define>
tag is of type Object
if you don't specify a value
attribute. The <html:option>
tag only works if the passed value is of type String
.
Use EL (Expression Language) to get the value instead:
<html:option value="${textVal}">
...
</html>
You could also just use the <html:optionsCollection>
tag and not have to explicitly iterate:
<html:select property="selectedServices" name="specificStoreForm" multiple="true" styleClass="services">
<html:optionsCollection name="services" property="selectedServices" value="value" label="label"/>
</html:select>