« Return to Thread: Getting OPTGROUP items to appear in the right order within a larger top-level SELECT list

Getting OPTGROUP items to appear in the right order within a larger top-level SELECT list

by mlevin :: Rate this Message:

Reply to Author | View in Thread

** Many apologies if this goes through twice -- I posted a few hours ago and didn't see my own post show up yet **

Hi folks,
 
I'm having some trouble getting my SELECT menu to appear the way I want it in a new Struts 2 project.
 
What I want is something like this:
 
Apple
Banana
Cookies
     Chocolate Chip
     Oatmeal
     Peanut Butter
Drinks
     Coke
     Sprite
Falafel
Gumdrops
 
In my code I have something like this:
 
<s:select name="choices" list="topLevelList" size="11" multiple="true">
     <s:optgroup label="Cookies" list="cookieList"/>
     <s:optgroup label="Drinks" list="drinkList"/>
</s:select>
 
topLevelList contains Apple, Banana, Falafel, Gumdrops
cookieList contains Chocolate Chip, Oatmeal, Peanut Butter
drinkList contains Coke, Sprite
 
But Struts is putting the OPTGROUP items at the end, so the list comes out like:
 
Apple
Banana
Falafel
Gumdrops
Cookies
     Chocolate Chip
     Oatmeal
     Peanut Butter
Drinks
     Coke
     Sprite
 
How can I get it to put the OPTGROUP things in the middle so I can keep my list in the order I want? I want to intersperse some OPTGROUP choices within a larger list of top-level choices.
 
Is there any way to do this?
 
Thanks!

 « Return to Thread: Getting OPTGROUP items to appear in the right order within a larger top-level SELECT list