I'm developing an application in Struts, where I need to have drop downs in my jsp. I'm using treemap in my form bean's reset() to populate the drop down in the jsp. the problem is, how can I get to the individual values in the drop down? here's my code..
Thank you Merrill.. I got the drop down working, but the selection it returns in the success page is wrong, and the corresponding value it returns is also wrong. Any suggestions on where I'm going wrong? Here's the code in my success.jsp.
<p>Your selection is:<bean:write name="LoginForm" property="hobby" /></p> ---- This prints the value associated with my
display text in the drop down.
<p>The value of your selection is:<bean:write name="LoginForm" property="key" /></p> --- This prints nothing!
posted 11 years ago
You've specified a code and a label for each code. What gets submitted to the server when the user presses the submit button is only the code, not the label. So, for example, if the user selected "Sleeping", the value of the tag should be "1". If you want the label "Sleeping" to appear, you'll have to translate it using the map.
In reference to the code above, I've another situation where I have to access data in one form bean in another form bean. Currently, I'm able to access the HobbyMap which is in one form bean in the other form bean, but I'm not able to get to its selected value. Here's my code in the other form bean, which I use to access the data in the first form bean:
Any help regarding this please? Thanks in advance.
He loves you so much! And I'm baking the cake! I'm going to put this tiny ad in the cake: