struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hong, Hoa" <hoa.h...@belointeractive.com>
Subject RE: How Do I Get Multiple Select to Work!
Date Mon, 11 Feb 2002 21:36:54 GMT
I appreciate Keith's response but I have already done that in my code. If I
replaced SRObject by SRObject[0] it works fine but it only puts a single
selected option in SRObject[0] when I submit the form(as it should.) My
problem is to get multiple select to work. If any of you have a working
example with multiple select please show me and let me know what version of
Struts you have.

Thank you in anticipation!
Hoa

-----Original Message-----
From: Keith Bacon [mailto:keithbaconstruts@yahoo.com]
Sent: Monday, February 11, 2002 11:47 AM
To: Struts Users Mailing List
Subject: Re: How Do I Get Multiple Select to Work!


Hi,
property="<%= \"userResponse[\"+ rIndex++ +\"].SRObject\"%>"
looks a bit dodgy to me.

your form bean only needs to have
public void setSelectedCarBrands(String[] selectedCarBrands) {..}
public String[] getSelectedCarBrands() [...]

then in your jsp 
property="selectedCardBrands"
maybe helped? code not tried but should work?
your code looks like you expext struts to want an indexed property in your
form bean.
It just calls the get/set once with the array parameter.

K.


--- "Hong, Hoa" <hoa.hong@belointeractive.com> wrote:
> Please help! I am not sure if I miss or misunderstand anything. 
> It lets me high light multiple items but when I summit the form 
> it does not puts any of the selected options in the property array, 
> SRObject which is an array of strings as I expected. 
> SROjbect has whatever values I initially set it to. 
> 
> Thank you in anticipation! 
> Hoa 
> 
> P.S.: I have enclosed my code: 
> 
> <html:select name="surveyForm" multiple="true" property="<%=
> \"userResponse[\"+ rIndex++ +\"].SRObject\"%>" size="5"> 
>     <html:option value="Acura" > Acura</html:option> 
>     <html:option value="Alfa Romeo" > Alfa Romeo</html:option> 
>     <html:option value="Am General" > Am General</html:option> 
>     <html:option value="American Motors" > American Motors</html:option>

>     <html:option value="Aston Martin" > Aston Martin</html:option> 
>     <html:option value="Audi" > Audi</html:option> 
> </html:select> 
> 
> public final class ScreenerResponseForm extends ActionForm { 
> ... 
> private String[] SRObject = null; 
> 
> public Object[] getSRObject() 
> { 
>     return SRObject;
> } 
> 
> public void setSRObject(String[] srobject) 
> { 
>     SRObject = srobject;
> } 
> 
> public Object getSRObject(int index) 
> { 
>     return Array.get(SRObject, index);
> } 
> 
> public void setSRObject(int index, Object element) 
> { 
>     Array.set(SRObject, index, element); 
> } 
> ... 
> } 
> 
> public class SurveyForm extends ActionForm { 
> ... 
> private Vector userResponse = new Vector(3, 1); 
> 
> public Vector getUserResponse() 
> { 
>     return userResponse; 
> } 
> public ScreenerResponseForm getUserResponse(int index) 
> { 
>     return (ScreenerResponseForm) userResponse.elementAt(index);
> } 
> public void setUserResponse(int index, ScreenerResponseForm newResponse) 
> { 
>     userResponse.add(index, newResponse); 
> } 
> public void setUserResponse(ScreenerResponseForm newResponse) 
> { 
>     userResponse.add(newResponse); 
> }
> ... 
> } 
> 
> --
> To unsubscribe, e-mail:
<mailto:struts-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
<mailto:struts-user-help@jakarta.apache.org>
> 


__________________________________________________
Do You Yahoo!?
Send FREE Valentine eCards with Yahoo! Greetings!
http://greetings.yahoo.com

--
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