This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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

"html:option" using properties file to load options

Praveen Teegala

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.

Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32481

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

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Praveen Teegala

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.
4=American Samoa
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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: "html:option" using properties file to load options
jQuery in Action, 3rd edition