how to populate ArrayList from Action to JSP?

I need full example if possiblethanks,
[52 byte] By [navrsalea] at [2007-10-2 6:39:12]
# 1
I forgot: ArrayList contains just Strings, not beans so there is no need for LabelBean and similar solution. JSP must present this ArrayList using <html:options> tag.
navrsalea at 2007-7-16 13:47:23 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

I used example from book Struts in Action page 296 (one collection stored as separate bean) according to which collection has been put directly in the request, session or application scope under the name ss:

<html:select property="ss">

<html:options collection="ss"/>

</html:select>

The problem is in JSP I get error:

java.lang.IllegalArgumentException: No name specified!?

refering to line <html:options collection="ss"/>

Anybody?

navrsalea at 2007-7-16 13:47:23 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

I also tried this:

<bean:define id="ss" name="tt"

property="ss" type="java.util.Collection"/>

<html:options collection="ss" property="value"

labelProperty="label"/>

the form tt is DynaValidatorForm

but get error:

javax.servlet.jsp.JspException: No getter method for property ss of bean tt

In my action I do:

ArrayListal = new ArrayList();

al.add( new String("str1" ));

...

request.setAttribute( "ss", al );

navrsalea at 2007-7-16 13:47:23 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

Consider an arraylist called joel which i return to a jsp page from my action class

request.setAttribute("goan", joel);

return (mapping.findForward("success"));

Here's how i display the contents of the ArrayList in my jsp page

<logic:present name="goan" scope="request">

<html:select size="1" property="goan" style="color: #000000; font-family: Garamond; font-size: 12pt">

<logic:iterate name="goan" id="obj" type="java.lang.String">

<html:option value="<%=obj%>"><bean:write name="obj"/> </html:option>

</logic:iterate>

</html:select>

Hope this helps

joel_savioa at 2007-7-16 13:47:23 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
it doesn't help. I get error:javax.servlet.jsp.JspException: No getter method available for property ss for bean under name org.apache.struts.taglib.html.BEAN!?
navrsalea at 2007-7-16 13:47:23 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
Did you find a solution? I also have same problem. Having a arraylist with values and need to populate it in html:options. No need for labelvalue.Pleas let me know.Thanks
laks77a at 2007-7-16 13:47:23 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7

It should work like this

<html:select property="your property name">

<html:options collection="arrayList name" value="gettermethod name of your bean" labelProperty="getter method name of your bean containing description" />

</html:select>

let me know if it still doesnot work. I will give the code

BJayaPrakasha at 2007-7-16 13:47:23 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8
yeah I have written like this only..can you please sned me the codeThanks
laks77a at 2007-7-16 13:47:23 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 9

This is not the best way of doing this as scripting in jsp is not a good idea and I haven't tried this for html:option, nonetheless, here's one way to do it:

Try setting the value in var first

<!--Looping logic using c:forEach-->

<c:forEach var="variable1" item="some_object">

<c:set var="var1" value="${variable1}" scope="page'/>

<!--html:select blah blah-->

<html:options value="><%=pageContext.requestAttribute('var1').toString()%>">

<!--blah blah-->

dah_cool_onea at 2007-7-16 13:47:23 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 10
how to populate ArrayList from Action to JSP
shrisaia at 2007-7-16 13:47:23 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...