java - Wicket, How can a DropDownChoice select change the options of another DropDownChoice? -


There is something in the wicket to drop the two option so that the first selection of the first Doprdownchoice Does the option change all the options?

You must use the value of the first choice to determine the value of the second one.

I used this example to select a AjaxFormComponentUpdatingBehavior that triggers Ajax updates and changes the value to use. I am providing a simple example of popularizing the second DropDownChoice with the federal states of the country, which is selected in the first one.

Note that I am using the wicket in 1.4. This example, although in newer versions, should not be very different.

  // two country final string aut = "AUT"; Last string ger = "ger"; // their final list of states & lt; String & gt; AutStates = Arrays.asList (new string [] {"V", "T", "S", "W"}); Last list & lt; String & gt; GerStates = Arrays.asList (new string [] {"NRW", "B", "BW"}); // mapping, you should actually get this data from a service or a stable last map & lt; String, list & lt; String & gt; & Gt; CountryTestat = New Hashmap & lt; String, list & lt; String & gt; & Gt; (2); Countrytaste.french (or, octets); CountryToTest Input (ger, gerstates); // WebMarkupContainer cont = new WebMarkupContainer ("cont") to send container back via AJAX final; Cont.setOutputMarkupId (right); (Remaining part); The last model & lt; String & gt; State Model = New Model & lt; String & gt; (); Last dropdown choice & lt; String & gt; Countries = New DropDownChoice & LT; String & gt; ("Country", the new model & lt; string & gt; (), new ArrayList & lt; string & gt; (countryToState.keySet ()); Last dropdown choice & lt; String & gt; States = New DropDownChoice & LT; String & gt; ("States", stateModel, New LoadableDetachableModel & LT; from string & gt; & gt; () {@Override from the protected list & lt; string & gt; load () {last string country = countries.getModelObject (); & Lt; string & gt; list = countryToState.get (country) from the last list; return list! = Null? List: New Arrelist & lt; string & gt; (0);}}); Countries.add (New AjaxFormComponentUpdatingBehavior ("onchange") {@Override Zero onUpdate (AjaxRequestTarget Goal) {Protected // just add container results to target.addComponent (the remaining part);}}); Cont.add (countries); Cont.add (states);  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -