View Javadoc

1   package org.appfuse.webapp.pages.components.country;
2   
3   import org.apache.wicket.markup.html.form.DropDownChoice;
4   import org.apache.wicket.model.PropertyModel;
5   import org.apache.wicket.spring.injection.annot.SpringBean;
6   import org.appfuse.webapp.services.SimpleCountryService;
7   
8   import java.util.ArrayList;
9   
10  /**
11   * A components wrapping drop down components with countries.
12   *
13   * @author Marcin ZajÄ…czkowski, 2013-11-18
14   */
15  public class SimpleCountryDropDownChoice extends DropDownChoice<String> {
16  
17      @SpringBean(name = "simpleCountryService")
18      private SimpleCountryService countryService;
19  
20      public SimpleCountryDropDownChoice(String id, PropertyModel<String> country) {
21          super(id, country, new ArrayList<String>());
22      }
23  
24      @Override
25      protected void onInitialize() {
26          super.onInitialize();
27          setChoices(countryService.getAvailableCountryCodesInLocale(getLocale()));
28          setChoiceRenderer(new SimpleCountryChoiceRenderer(getLocale()));
29      }
30  }