Re: Dynamic Optgroups in Wicket
Thanks Mike and everyone who responded. I did manage to find a working solution by creating a OptGroup component by extending WebMarkupContainer and using fragments... But was then was disheartened as it appears that you cannot nest optgroups inside one another in html - To represent the multiple levels within my list hierarchy. If there is such a way to nest optgroups within one another, then I would very much appreciate the info but I suspect you can't from what I've read. My final solution was just to use a select component and replace the labels using hyphens before the text to represent the current level: Item1---Item1-1---Item1-2---Item1-3Item2---Item2-1---Item2-2--Item2-2-1--Item2-2-2---Item2-3Item3 Thanks Gary --- On Tue, 9/1/09, Michael O'Cleirigh michael.ocleir...@rivulet.ca wrote: From: Michael O'Cleirigh michael.ocleir...@rivulet.ca Subject: Re: Dynamic Optgroups in Wicket To: users@wicket.apache.org Date: Tuesday, September 1, 2009, 12:03 PM Hi Gary, Hi,I am kind of new to Wicket and am having a difficult time finding some decent info on creating optgroups within selects.I basically have a structured list in my DB which in turn has children - perfect solution would be to use dynamically generated optgroups with their children which will of course be option tags.All the examples containing optgroups seem to have the optgroups fixed in markup with no wicket:ids.Any thoughts would be most welcomed.Gary I created a custom implementation of SelectOptions and SelectOption (in wicket-extensions) that I use to render the optgroups. What I do is use a wrapping object that contains the business object and the name of the optgroup and if it is the first or last wrapping object with that particular optgroup name. Then I override the SelectOptions.newOption(...) to wire in my custom CustomSelectOption. Note that newOption() is called in order for each option in the list so tracking the last optiongroup name can be used to determine if its changed or not. i.e. if the Custom.SlectOption.startOptionGroup or the CustomSelectOption.endOptionGroup parameter should be true or false. This is the only change in the selectOption: �...@override protected void onRender(MarkupStream markupStream) { /* * Write out the option group wrappings if this is the first or last option in a particular group. */ if (startOptionGroup) { getResponse().write(optgroup label=\ + optionGroupName + \ + optionGroupName + \n); } super.onRender(markupStream); if (endOptionGroup) { getResponse().write(/optgroup\n); } } The setting of the start and end flags are handled in SelectOptions.newOption(...) and then the above code is used to render the options into optiongroups. Let me know if you need more details, Regards, Mike - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Dynamic Optgroups in Wicket
Hi,I am kind of new to Wicket and am having a difficult time finding some decent info on creating optgroups within selects.I basically have a structured list in my DB which in turn has children - perfect solution would be to use dynamically generated optgroups with their children which will of course be option tags.All the examples containing optgroups seem to have the optgroups fixed in markup with no wicket:ids.Any thoughts would be most welcomed.Gary
Re: Dynamic Optgroups in Wicket
correction: In your application u CAN populate your list of options, and pass it to an similar component. On Tue, Sep 1, 2009 at 9:07 AM, Pedro Santos pedros...@gmail.com wrote: Gary, Take a look at wicket.markup.html.form.DropDownChoicehttp://wicketstuff.org/wicket13/compref/;jsessionid=9632D2AC608C8E9715009EAA5EEBD3FF?wicket:bookmarkablePage=:org.apache.wicket.examples.compref.DropDownChoicePageat http://wicketstuff.org/wicket13/compref/ on these examples, the option values ar not fixed in markup with no wicket:ids. They are passed to constructor of 2 lists that are used by DropDownChoice component model. In your application u can't populate your list of options, and pass it to an similar component. On Tue, Sep 1, 2009 at 8:57 AM, gary black gar20...@yahoo.com wrote: Hi,I am kind of new to Wicket and am having a difficult time finding some decent info on creating optgroups within selects.I basically have a structured list in my DB which in turn has children - perfect solution would be to use dynamically generated optgroups with their children which will of course be option tags.All the examples containing optgroups seem to have the optgroups fixed in markup with no wicket:ids.Any thoughts would be most welcomed.Gary
Re: Dynamic Optgroups in Wicket
Looking at the API docs for the Select component, it would seem to be designed for more complex select situations (multi-select and optgroups). Unfortunately, I can't find any examples on using it with dynamically generated optgroups. Can anyone clarify how you would use the component like this, or suggest an alternative? Pedro Santos wrote: correction: In your application u CAN populate your list of options, and pass it to an similar component. On Tue, Sep 1, 2009 at 9:07 AM, Pedro Santos pedros...@gmail.com wrote: Gary, Take a look at wicket.markup.html.form.DropDownChoicehttp://wicketstuff.org/wicket13/compref/;jsessionid=9632D2AC608C8E9715009EAA5EEBD3FF?wicket:bookmarkablePage=:org.apache.wicket.examples.compref.DropDownChoicePageat http://wicketstuff.org/wicket13/compref/ on these examples, the option values ar not fixed in markup with no wicket:ids. They are passed to constructor of 2 lists that are used by DropDownChoice component model. In your application u can't populate your list of options, and pass it to an similar component. On Tue, Sep 1, 2009 at 8:57 AM, gary black gar20...@yahoo.com wrote: Hi,I am kind of new to Wicket and am having a difficult time finding some decent info on creating optgroups within selects.I basically have a structured list in my DB which in turn has children - perfect solution would be to use dynamically generated optgroups with their children which will of course be option tags.All the examples containing optgroups seem to have the optgroups fixed in markup with no wicket:ids.Any thoughts would be most welcomed.Gary - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Dynamic Optgroups in Wicket
I'm not sure this is what you want, but have a look at this: http://www.wicket-library.com/wicket-examples/ajax/choice It's drop down with ajax. What they did is setting in the model Map of values. Eyal Golan egola...@gmail.com Visit: http://jvdrums.sourceforge.net/ LinkedIn: http://www.linkedin.com/in/egolan74 P Save a tree. Please don't print this e-mail unless it's really necessary On Tue, Sep 1, 2009 at 4:33 PM, Iain Reddick iain.redd...@beatsystems.comwrote: Looking at the API docs for the Select component, it would seem to be designed for more complex select situations (multi-select and optgroups). Unfortunately, I can't find any examples on using it with dynamically generated optgroups. Can anyone clarify how you would use the component like this, or suggest an alternative? Pedro Santos wrote: correction: In your application u CAN populate your list of options, and pass it to an similar component. On Tue, Sep 1, 2009 at 9:07 AM, Pedro Santos pedros...@gmail.com wrote: Gary, Take a look at wicket.markup.html.form.DropDownChoice http://wicketstuff.org/wicket13/compref/;jsessionid=9632D2AC608C8E9715009EAA5EEBD3FF?wicket:bookmarkablePage=:org.apache.wicket.examples.compref.DropDownChoicePage at http://wicketstuff.org/wicket13/compref/ on these examples, the option values ar not fixed in markup with no wicket:ids. They are passed to constructor of 2 lists that are used by DropDownChoice component model. In your application u can't populate your list of options, and pass it to an similar component. On Tue, Sep 1, 2009 at 8:57 AM, gary black gar20...@yahoo.com wrote: Hi,I am kind of new to Wicket and am having a difficult time finding some decent info on creating optgroups within selects.I basically have a structured list in my DB which in turn has children - perfect solution would be to use dynamically generated optgroups with their children which will of course be option tags.All the examples containing optgroups seem to have the optgroups fixed in markup with no wicket:ids.Any thoughts would be most welcomed.Gary - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org