• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to use html:options

 
Prakash Dwivedi
Ranch Hand
Posts: 452
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello friends,
I am trying to use html:select tag with html ptions but unable to use it.
i have one jsp page, one form class, in my form class i have following method
public Iterator getCountryList()
{
System.out.println("i am in getCountryList");
ArrayList country = new ArrayList();
country.add("India");
country.add("USA");
country.add("UK");
country.add("Gremany");
country.add("France");
countryList = country.iterator();
return countryList;
}
following is the code i used in my jsp page
<html:select property="countryList">
<html ptions collection="user"/>
</html:select>
Here user is a bean which is bound in session and contains countryList as a variable(apart from form class)
actually i am very much confused about these attributes, and not able to use them ptoperly
I am getting following error
javax.servlet.jsp.JspException: Cannot create iterator for app.LogonForm@14dc

thanx
 
Lalitha Chandran
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Here is how I use the html select options tag. I am using the LabelValueBean Class which comes along with struts. org.apache.struts.util.LabelValueBean)
JSP File:

Action File:

Action Form file

Hope this helps.
Lalitha
 
Prakash Dwivedi
Ranch Hand
Posts: 452
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Lalitha
 
xinglee vn
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi !
can you show me how to set value for <html ption> using bean ? (I am beginner in Struts)
i have :
<logic:iterate id="exp" name="beanname">
<html:select property="Dept">
<html ption name="exp" value="<bean:write name="exp" property="id">"/>
</html:select>
</logic:iterate>
but it doesn't work ! pls help me as soon as posible . it's very Urgen . Thanks a lot
 
Ron Yoshimochi
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to struts and I tried the sample below. Could you post the struts-config.xml
Thanks
Ron
Originally posted by Lalitha Chandran:
Hi
Here is how I use the html select options tag. I am using the LabelValueBean Class which comes along with struts. org.apache.struts.util.LabelValueBean)
JSP File:

Action File:

Action Form file

Hope this helps.
Lalitha
 
Kavita Ghia
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx Lalitha, your code really helped !!!
 
A Patel
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Lalitha - I was trying to populate a dates drop down for the past two weeks and your code (using LabelValueBean) solved my problem in a matter on minutes.

Thanks a ton!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic