Problem with Struts 1.1 and select box

C

cccc

Hi,
I have a problem with this java code:

I want populate a select box with Jakarta Struts 1.1

<%
String multipleValues[] =
{ "Multiple 0", "Multiple 1", "Multiple 2", "Multiple 3", "Multiple 4",
"Multiple 5", "Multiple 6", "Multiple 7", "Multiple 8", "Multiple 9" };
pageContext.setAttribute("multipleValues", multipleValues);
%>

<html:select property="multipleSelect" size="10" multiple="true">
<html:eek:ptions name="multipleValues" labelName="multipleValues"/>
</html:select>

Can you help me?

Ciao,
Carlo
 
D

Dirk Michaelsen

Hi,

you do it the wrong way. Maybe you should have taken a look into the
struts examples ;-)

This way it should work:

<%
ArrayList multipleValues = new ArrayList();
multipleValues.add(new LabelValueBean("Multiple 0", "0"));
multipleValues.add(new LabelValueBean("Multiple 1", "1"));
multipleValues.add(new LabelValueBean("Multiple 2", "2"));
// ...
request.setAttribute("multipleValues", multipleValues);
%>

<html:select property="multipleSelect" size="10" multiple="true">
<html:eek:ptions collection="multipleValues" property="value"
labelProperty="label"/>
</html:select>


Ideally you don't do the above initialization part in the jsp but in
the ActionForms reset method.

cu Dirk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,251
Latest member
41Ki

Latest Threads

Top