• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to use html:options

 
Ranch Hand
Posts: 452
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Lalitha
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanx Lalitha, your code really helped !!!
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Right! We're on it! Let's get to work tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic