You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Raible, Matt" <Ma...@cable.comcast.com> on 2003/03/04 20:15:55 UTC
select multiple="true" and setting properties
I have an ActionForm with the following:
ArrayList msoIds;
public ArrayList getMsoIds() {
return msoIds;
}
public void setMsoIds(ArrayList msoIds) {
this.msoIds = msoIds;
}
Now I have a JSP that displays a <select> with the ability to select
multiples:
<html:select multiple="true" property="msoIds"
styleId="msoIds" size="10">
<html:options collection="userMsoList" property="value"
labelProperty="label"/>
</html:select>
However, as you probably know, I get an exception when Struts does
BeanUtils.copyProperties - can't convert String to ArrayList.
I tried adding indexed setters for the multiple select:
public String getMsoIds(int index) {
return (String) msoIds.get(index);
}
public void setMsoIds(int index, String msoId) {
msoIds.set(index, msoId);
}
but this results in the following error:
Caused by: java.lang.NoSuchMethodException: Property 'msoIds' has no setter
method
I saw stuff in the mailing list about naming the indexed properties
different, and I tried this (also renaming the <select>), but then my page
stops loading when it hits the new name (allowedMSOs). Using tiles hides
all the errors :(.
Any ideas are appreciated.
Matt
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Multi-level validation
Posted by Carl Fyffe <st...@sixty4bit.com>.
Currently, my project is doing validation by overidding the validate()
method of ActionForm. We use nesting quite a bit, and today I came upon
a "hurdle". I need to validate two nested forms. I was expecting to be
able to do:
ActionErrors errors = nestedForm.validate(map, req);
Errors.addAll(nestedForm2.validate(map, req));
But the addAll isn't there. Is this by design or have I missed
something?
Suggestions welcome,
Carl
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: select multiple="true" and setting properties
Posted by John Devine <jo...@comcast.net>.
Matt,
Does it have to be an ArrayList?
Could you get away with just an Array?
I use String arrays in my Action forms for multiple selects and haven't
had a problem with that.
-----Original Message-----
From: Raible, Matt [mailto:Matt_Raible@cable.comcast.com]
Sent: Tuesday, March 04, 2003 1:16 PM
To: 'struts-user@jakarta.apache.org'
Subject: select multiple="true" and setting properties
I have an ActionForm with the following:
ArrayList msoIds;
public ArrayList getMsoIds() {
return msoIds;
}
public void setMsoIds(ArrayList msoIds) {
this.msoIds = msoIds;
}
Now I have a JSP that displays a <select> with the ability to select
multiples:
<html:select multiple="true" property="msoIds"
styleId="msoIds" size="10">
<html:options collection="userMsoList" property="value"
labelProperty="label"/>
</html:select>
However, as you probably know, I get an exception when Struts does
BeanUtils.copyProperties - can't convert String to ArrayList.
I tried adding indexed setters for the multiple select:
public String getMsoIds(int index) {
return (String) msoIds.get(index);
}
public void setMsoIds(int index, String msoId) {
msoIds.set(index, msoId);
}
but this results in the following error:
Caused by: java.lang.NoSuchMethodException: Property 'msoIds' has no
setter
method
I saw stuff in the mailing list about naming the indexed properties
different, and I tried this (also renaming the <select>), but then my
page
stops loading when it hits the new name (allowedMSOs). Using tiles
hides
all the errors :(.
Any ideas are appreciated.
Matt
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org