Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts and JSP

 
janice ang
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I would like to know how can i display my bean:write value together with the existing value in the drop down menu in a way that there will be no repetition in my values?

<html:form action="UpdatePersonalDetails" onsubmit="return validatePersonalDetailsFormBean(this)">

<logic:iterate id="Student" name="studentList">

<select name="randomAssignTeam">
<option value="<bean:write name='Student' property='randomAssignTeam'/>" key="selected"><bean:write name='Student' property='randomAssignTeam'/></option> <option value="No">No</option>
<option value="Yes">Yes</option> </select>

For example, my bean:write value is Yes. With the above codes, the drop down will show Yes, No, Yes instead of only Yes, No
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64967
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to post Struts questions in the Struts forum. I have moved this post there for you.
 
Nacho Espinosa
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi janice:

This is your code:

<logic:iterate id="Student" name="studentList">

<select name="randomAssignTeam">
<option value="<bean:write name='Student' property='randomAssignTeam'/>" key="selected"><bean:write name='Student' property='randomAssignTeam'/></option> <option value="No">No</option>
<option value="Yes">Yes</option> </select>

I notice that the iterate tag is out of select, then when iterate works, draw many times your select tag, and other tags.

Maybe you should use the optionCollection tag.

Or to do the next:

<logic:iterate id="Student" name="studentList">

<select name="randomAssignTeam">
<logic:iterate id="Student" name="studentList">
<option value="<bean:write name='Student' property='randomAssignTeam'/>" key="selected"><bean:write name='Student' property='randomAssignTeam'/></option>
</logic:iterate>
<option value="No">No</option>
<option value="Yes">Yes</option> </select>

But I suggest the first option.



Bye
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic