Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Struts and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark ""html:option" using properties file to load options" Watch ""html:option" using properties file to load options" New topic
Author

"html:option" using properties file to load options

Praveen Teegala
Greenhorn

Joined: Apr 03, 2004
Posts: 11
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.


Praveen
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30965
    
158

Praveen,
If you leave out the "key" attribute, it will default to the value. So having them both is redundant.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Praveen Teegala
Greenhorn

Joined: Apr 03, 2004
Posts: 11
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: "html:option" using properties file to load options