This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30138
    
150

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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: "html:option" using properties file to load options
 
Similar Threads
update html:options
Code optimization for html:option tag
HTML:SELECT
assign two properties to a submit button
how to set option to default ?