Package javango.forms.fields

Examples of javango.forms.fields.SelectField


    }
   
  }
 
  public void testDefaultWidget() throws Exception {
    Field f = new SelectField(injector.getInstance(WidgetFactory.class));
    assertEquals(SelectWidget.class, f.getWidget().getClass());
  }
View Full Code Here


    }
   
  }
 
  public void testDefaultWidget() throws Exception {
    Field f = new SelectField(injector.getInstance(WidgetFactory.class));
    assertEquals(SelectWidget.class, f.getWidget().getClass());
  }
View Full Code Here

 
  public void testRequired() throws Exception {
    Map<String, String> choices = new HashMap<String, String>();
    choices.put("1", "1");
    choices.put("2", "2");
    Field<String> f = new SelectField(injector.getInstance(WidgetFactory.class)).setChoices(choices).setName("choice_field");
   
    Map<String, String> errors = new HashMap<String, String>();
   
    f.clean(new String[]{""}, errors);
    assertEquals("This field is required.", errors.get("choice_field"));
View Full Code Here

 
  public void testNotRequired() throws Exception {
    Map<String, String> choices = new HashMap<String, String>();
    choices.put("1", "1");
    choices.put("2", "2");
    Field<String> f = new SelectField(injector.getInstance(WidgetFactory.class)).setChoices(choices).setName("choice_field").setRequired(false);
   
    Map<String, String> errors = new HashMap<String, String>();
   
    assertEquals(null, f.clean(new String[]{""}, errors));
    assertTrue(errors.isEmpty());
View Full Code Here

 
  public void testAllowNull() throws Exception {
    Map<String, String> choices = new HashMap<String, String>();
    choices.put("1", "1");
    choices.put("2", "2");
    Field<String> f = new SelectField(injector.getInstance(WidgetFactory.class)).setChoices(choices).setName("choice_field").setRequired(false).setAllowNull(true);
   
    Map<String, String> errors = new HashMap<String, String>();
   
    assertEquals(null, f.clean(new String[]{""}, errors));
    assertTrue(errors.isEmpty());
View Full Code Here

 
  public void testGetByValue() throws Exception {
    Map<String, String> choices = new HashMap<String, String>();
    choices.put("J", "John");
    choices.put("P", "Paul");
    Field<String> f = new SelectField(injector.getInstance(WidgetFactory.class)).setChoices(choices).setName("choice_field");
   
    Map<String, String> errors = new HashMap<String, String>();
   
    assertEquals("J", f.clean(new String[]{"J"}, errors));
    assertTrue(errors.isEmpty());
View Full Code Here

    Map<String, String> choices = new LinkedHashMap<String, String>();
    choices.put("1", "One");
    choices.put("2", "Two");
    SelectWidget w = new SelectWidget();
    ChoiceField field = (ChoiceField) new SelectField(injector.getInstance(WidgetFactory.class)).setChoices(choices).setAllowNull(false).setName("pickme");
//    w.setField(field);
   
    String[] o = w.valueFromMap(postData, "pickme");
    assertEquals("2", o[0]);
   
View Full Code Here

    public FrameworkForm(FieldFactory fieldFactory, WidgetFactory widgetFactory) {
      super(fieldFactory);
      Map<String, String> choices = new LinkedHashMap<String, String>();
      choices.put("P", "Python");
      choices.put("J", "Java");
      language = new SelectField(widgetFactory).setChoices(choices).setWidget(new RadioWidget());
      init();
    }
View Full Code Here

TOP

Related Classes of javango.forms.fields.SelectField

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.