I am new to struts i am stuck on an issue in the code of my project as part of that
i need to populate an Arraylist elements into an html option in the JSP i mean a drop down
with value and label being the same as option value.
My ActionClass Contains
i am assigining in the following way in to my bean in one of my previous action class
ArrayList alist = new ArrayList();
for (int i=1;i<=30;i++)
{
alist.add(i);
}
atdForm.setAtDate(alist);
But i am unable to generate the desired result , i am not sure i am coding in the correct way , or can suggest the best way .Appreciate your help. Thanks.
Please UseCodeTags when posting code or configuration. Unformatted code and configuration is very difficult to read. You can edit your post to include them by using the button.
RamandeepS Singh
Ranch Hand
Joined: Aug 25, 2009
Posts: 59
posted
0
you can do something like this
ArrayList alist = new ArrayList();
for (int i=1;i<=30;i++)
{
alist.add(i);
}
request.setAttribute("alist",alist);
then in jsp you can retreive this as given below
<html:select property="selList">
<logic:iterate name="alist" id="element"> // as name is name of attribute in some scope
<htmlption name="dateList" value="<bean:write name="element"/>"><bean:write name="element"/></htmlption>
</logic:iterate>
</html:select>
hope this helps
Ramandeep S
Srinivas Aravala
Greenhorn
Joined: Aug 20, 2005
Posts: 6
posted
0
Hi Ramandeep,
Thanks for your reply , i have tried in the way you suggested but still i am having the below problem
Thanks for your revert, seems doesnt have attribute name
javax.servlet.ServletException: org.apache.jasper.JasperException: /GetAttDetails.jsp(115,0) Attribute name invalid for tag option according to TLD
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:286)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
but i was able to solve the issue in the following way