I haven't tried it, but I'd assume you would have to register a
converter for String[], rather than just String. What does your
converter registration code look like?
L.
BISO wrote:
Thanks Laurie for your response.
I used BeanUtils and It worked well with me :)
Unfortunately, convert(Class type, Object value) works only with single
Object not Object array. Do you know away to make it work with arrays.
My goal to Convert String[] to a java.util.Set
Thanks again
BISO
Laurie Harper wrote:
That's because Struts doesn't know how to turn a set of HTML request
parameters into a Set of Something. There are a couple of options: you
could, perhaps, register a converter with BeanUtils what would do this
for you, at which point your existing code would probably work as you
were expecting; or you could change your form bean to expose the
'values' field as an indexed property [1]. The latter is probably the
one you want.
L.
[1] http://struts.apache.org/1.2.9/userGuide/building_view.html#indexed
BISO wrote:
Dears,
I have a "User" bean with java.util.Set property.
I create a struts form with a list to select multiple values from and
then
store them in the set.
I am getting this exception:
java.lang.IllegalArgumentException: Cannot invoke
com.myapp.struts.User.setValues - argument type mismatch
---
public class User extends org.apache.struts.action.ActionForm {
private String name;
private Set values;
public String getName() {
return name;
}
public void setName( String name) {
this.name = name;
}
public Set getValues() {
return values;
}
public void setValues(Set values) {
this.values = values;
}
}
----
<html:form action="/post">
<html:text property="name"/>
<html:select property="values" multiple="true">
<html:option value="1"/>
<html:option value="2"/>
<html:option value="3"/>
<html:option value="4"/>
<html:option value="5"/>
<html:submit />
</html:select>
</html:form>
------
Thanks in advance
BISO
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]