• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

html:options values getting appended

 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I just wrote a very simple struts example where I am populating a combo box with some values. I use <html ptions> for populating this. First I populate just 4 values, the page loads fine but when i refresh the page I see 8 values (ie the 4 values added twice) in the html combo box.
I have reset the session values etc still I am facing the same problem.
Some struts expert please help...
I am posting my code below...



Thanks in Advance
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sivaraman,
Try this out ..in JSP.

<bean efine id="lstplace" name="WelcomeForm" property="place"/>
<html:select property="selectedPlace">
<html ptions collection="lstplace" property="key" labelProperty="value"/>
</html:select>

Thanks
 
Sivaraman Lakshmanan
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thanks for your reply. I put the code that u gave in my JSP but its throwing a error when I run the page. The error is

javax.servlet.ServletException: No getter method available for property key for bean under name lstplace

help me to get rid of this error
 
Soumya Saha
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sivaraman,
Sorry for that..
u can do it either way..

1.Have a bean class ..like struts label value bean..with 2 attributes(Key and Value)...set ur dropdown values in the key and value attributes of the Bean and then add the bean in the arraylist.(u should have a new instance of the Bean every time while adding to the arrayList..hope u got my point..).Then that code should work..

2.Or else ..U can use a HashMap(lstPlace) and set the values like...HmMap.put("Chennai", "Chennai");..and set it in the Request Scope and acces it from the JSP ..Then u don't need to define any bean id..

Please get back incase of errors...

Thanks
 
Liar, liar, pants on fire! refreshing plug:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic