5

I have a lot of DropDownChoice components with many items in a form, and on loading the form, I'd like to display only the saved selected options. When the user clicks on a DropDownChoice, I'd like to ajax-load the full item list on the fly.

Can this be done?

Per
  • 636
  • 5
  • 8
  • That sounds a bit unorthodox, what if I want to use hotkeys to navigate? – biziclop Apr 05 '12 at 22:04
  • @bert: Maybe it was a bit unclear - saved values, the values selected the last time the user viewed the form. – Per Apr 06 '12 at 06:04
  • @biziclop: Perhaps it could be made to work with keys as well? – Per Apr 06 '12 at 06:04
  • @Per I can still see a lot of accessibility issues. Wouldn't it be easier to just lazy-load them? Although you can attach a behaviour to the "onfocus" event, that would probably work. – biziclop Apr 06 '12 at 10:59

3 Answers3

2

Add a OnChangeAjaxBehavior to your dropdown-component. Override the onUpdate-method and add another component to the target. The chosen value of the dropdown-component is inside its model.

Update: Okey, I think I know what you're trying to achieve. Add an AjaxFormComponentUpdatingBehavior to your dropdown component with "onclick" as constructor parameter. Override the onUpdate-method and add your dropdown component to the target. Before you do that, update the dropdown model, so that it now contains all values.

rotsch
  • 1,909
  • 16
  • 36
  • onchange implies just that - on change, that something happens when I change the value of the input. What I'm looking for is not having to transfer all the items of all the drop downs (many of which are the same) at page display time. I want to delay that until the user actually clicks on a drop-down. – Per Apr 05 '12 at 19:43
0

Maybe you could go with the AjaxEditableLabels... Using the AjaxEditableChoiceLabel from Wicket Extensions, you'll get a compponent that displays the current value as a Label until clicked and the changes to a DropDownChoice via Ajax. That should be pretty much like the solution you're looking for.

Nicktar
  • 5,548
  • 1
  • 28
  • 43
0

If you have a lot of options to show then using <select> is not the best option.

Better check http://ivaynberg.github.com/select2/ or http://livedocs.dojotoolkit.org/dijit/form/FilteringSelect or any other JS based component which can load options on demand via Ajax.

martin-g
  • 17,243
  • 2
  • 23
  • 35