Package javango.forms.fields

Examples of javango.forms.fields.BooleanField.clean()


    String[] value = form.getData().get(String.format("%s-%s", form.getPrefix(), deletionFieldName));
    if (value == null || value.length == 0) {
      return false;
    }
    try {
      return field.clean(value, new HashMap<String, String>());
    } catch (ValidationException e) {
      return false;
    }
  }
 
View Full Code Here


    Field field = new BooleanField(injector.getInstance(WidgetFactory.class));
    field.setName("fieldName");

    Map<String, String> errors = new HashMap<String, String>();
   
    field.clean(new String[]{""}, errors);
    assertFalse(errors.isEmpty());
    assertTrue(errors.containsKey(field.getName()));
    assertEquals("Required", errors.get(field.getName()));
  }
 
View Full Code Here

    field.setName("fieldName");
    field.setRequired(false);
   
    Map<String, String> errors = new HashMap<String, String>();
   
    field.clean(new String[]{""}, errors);
    assertTrue(errors.isEmpty());
  }

  public void testInvalid() throws Exception {
    Field field = new BooleanField(injector.getInstance(WidgetFactory.class));
View Full Code Here

    Field field = new BooleanField(injector.getInstance(WidgetFactory.class));
    field.setName("fieldName");
   
    Map<String, String> errors = new HashMap<String, String>();
   
    Boolean value = (Boolean)field.clean(new String []{"qwert"}, errors);
    assertFalse(errors.isEmpty());
    assertTrue(errors.containsKey("fieldName"));
    assertEquals("Unknown value 'qwert'", errors.get("fieldName"));
  }
View Full Code Here

    Field field = new BooleanField(injector.getInstance(WidgetFactory.class));
    field.setName("fieldName");
   
    Map<String, String> errors = new HashMap<String, String>();
   
    Boolean value = (Boolean)field.clean(new String[]{"true"}, errors);
    assertTrue(errors.isEmpty());
    assertEquals(Boolean.TRUE, value);
 

  public void testValidFalse() throws Exception {
View Full Code Here

    Field field = new BooleanField(injector.getInstance(WidgetFactory.class));
    field.setName("fieldName");
   
    Map<String, String> errors = new HashMap<String, String>();
   
    Boolean value = (Boolean)field.clean(new String[]{"false"}, errors);
    assertTrue(errors.isEmpty());
    assertEquals(Boolean.FALSE, value);
 

}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.