wood burning stoves*
The moose likes Struts and the fly likes set  html option value by bean: message key=... 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 "set  html option value by bean: message key=..." Watch "set  html option value by bean: message key=..." New topic
Author

set html option value by bean: message key=...

amit sharma
Ranch Hand

Joined: Jul 19, 2006
Posts: 129
I have select box in my page .I want that value attribute of <html ption > is written by <bean:message key="ddd"
For e.g.

But it gives error quote symbol expected .
Thanks
RoshaniG Gopal
Ranch Hand

Joined: May 15, 2006
Posts: 180
Hi
It should be <html ption value="<bean:write..../>">
Regards,
Roshani


Regards,<br />Roshani
amit sharma
Ranch Hand

Joined: Jul 19, 2006
Posts: 129
But then it output "<bean message........." as value and not which is specified in property file.
Thanks
RoshaniG Gopal
Ranch Hand

Joined: May 15, 2006
Posts: 180
hi,
Try using HTML tag. eg <option value="<bean:write..."/>
Actually it worked for me in case of text values. <input type="text value="bean:write.."/>
Reagrds,
Roshani
amit sharma
Ranch Hand

Joined: Jul 19, 2006
Posts: 129
It work if you use html tag but not if you use struts tag.
Thanks
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Firstly, you can't embed one Struts tag inside another. That's why it works for a regular <option> tag but not for an <htmlption> tag.

Secondly, using a message key for an option value is generally a really bad idea.

If this is an i18n application, the value will be different for each language. This means that in your Aciton class, you have to check for the value in each language to tell what action to take. Better to make the value a single string that is the same regardless of which language is being used.

The only situation where this would be useful is if you're storing the value in the database differently depending on the language spoken by the user.
[ October 13, 2006: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: set html option value by bean: message key=...
 
Similar Threads
update html:options
populate a combo drop down box by using the values defined in a resource file
select drop down question
bean:message tag in option tag. is there a solution?
Cannot retrieve mapping for action /