Hi, I just had the problem alike, where if my list of selectoptions was
empty, optgroup header was shown without any elements below, needed to hide
this optgroup tag:

Instead of developing OptGroup class, I used WebMarkupContainer and
SelectOptions components, together they worked fine for me, here is the java
code:
   
   Select mySelect = new Select("mySelect");
   WebMarkupContainer optgroup1WMC = new WebMarkupContainer("optgroup1");
   SelectOptions group1 = new SelectOptions("group1", someListOfElements1,
someRenderer1());
   optgroup1WMC.add(group1);
   optgroup1WMC.setVisible(someBoolVariable1);
   mySelect.add(optgroup1WMC);
   mySelect.add(group1);

   WebMarkupContainer optgroup2WMC = new WebMarkupContainer("optgroup2");
   SelectOptions group2 = new SelectOptions("group2", someListOfElements2,
someRenderer2());
   optgroup2WMC.add(group2);
   optgroup2WMC.setVisible(someBoolVariable2);
   mySelect.add(optgroup2WMC);
   mySelect.add(group2); 

   add(mySelect);

   and HTML code:

   <select wicket:id="mySelect">
   
   <optgroup wicket:message="Optgroup1.propertyname">
   <wicket:container wicket:id="group1">
            <option wicket:id="option"></option>
   </wicket:container>
   </optgroup>
   
   
   
   <optgroup wicket:message="OptGroup2.propertyname">
   <wicket:container wicket:id="group2">
            <option wicket:id="option"></option>
   </wicket:container>
   </optgroup>
   
   </select>

Hope it helps someone in future :)

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Dynamic-Select-and-SelectOptions-tp1872483p4508111.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to