Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

"html:option" using properties file to load options

 
Praveen Teegala
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am able to populate <html:select> with <html ptions> for which values
come from a properties file.
The problem is
I want to have the display and value for <html ption> the same.
Part of my code in jsp is like this.
<% for(int k = 1;k<226;k++){
%>
<html ption bundle="countries" key='<%= k+"" %>' value='<%= k+""%>'/>
<%}%>
Any help is highly appreciated.
Thank you all.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34071
331
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Praveen,
If you leave out the "key" attribute, it will default to the value. So having them both is redundant.
 
Praveen Teegala
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Boyarsky for the reply.
I tried as you said, but it is only populating the select with 1,2,3...etc..,
My properties file is like this.
0=Select
1=Afghanistan
2=Albania
3=Algeria
4=American Samoa
5=Andorra
6=Angola
etc...,
I want to display country names in the select, and also, when I read the selected value in action, I want the country name, not the number for it.
(Now I am again fetching the country for the key(number) from properties)
Is there any way to do it.
Thank you again.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic