Package javango.forms.widgets

Examples of javango.forms.widgets.Widget


   
    assertEquals("0.00", w.asText(value));
  }
 
  public void testEmptyArrayValueHtml() {
    Widget w = new DecimalInputWidget();
    Double[] value = new Double[]{};
    String output = w.render("field", value, new LinkedHashMap<String, Object>());
    String html = "<input type=\"text\" name=\"field\" />";
    assertEquals(html, output);
   
    assertEquals("", w.asText(value));
  }
View Full Code Here


public class TextWidgetTest extends InjectedTestCaseBase {

  private Log log = LogFactory.getLog(TextWidgetTest.class);
 
  public void testEmptyValueHtml() {
    Widget w = new TextInputWidget();
    String value = "";
    String output = w.render("field", value, new LinkedHashMap<String, Object>());
    String html = "<input type=\"text\" name=\"field\" />";
    assertEquals(html, output);
  }
View Full Code Here

    String html = "<input type=\"text\" name=\"field\" />";
    assertEquals(html, output);
  }

  public void testNullValueHtml() {
    Widget w = new TextInputWidget();
    String value = null;
    String output = w.render("field", value, new LinkedHashMap<String, Object>());
    String html = "<input type=\"text\" name=\"field\" />";
    assertEquals(html, output);
  }
View Full Code Here

    String html = "<input type=\"text\" name=\"field\" />";
    assertEquals(html, output);
  }
 
  public void testEmptyArrayValueHtml() {
    Widget w = new TextInputWidget();
    String[] value = new String[]{};
    String output = w.render("field", value, new LinkedHashMap<String, Object>());
    String html = "<input type=\"text\" name=\"field\" />";
    assertEquals(html, output);
  }
View Full Code Here

    String html = "<input type=\"text\" name=\"field\" />";
    assertEquals(html, output);
  }

  public void testStringHtml() {
    Widget w = new TextInputWidget();
    String value = "hello";
    String output = w.render("field", value, new LinkedHashMap<String, Object>());
    String html = "<input type=\"text\" name=\"field\" value=\"hello\" />";
    assertEquals(html, output);
  }
View Full Code Here

    String html = "<input type=\"text\" name=\"field\" value=\"hello\" />";
    assertEquals(html, output);
  }
 
  public void testStringArrayHtml() {
    Widget w = new TextInputWidget();
    String[] value = new String[]{"hello"};
    String output = w.render("field", value, new LinkedHashMap<String, Object>());
    String html = "<input type=\"text\" name=\"field\" value=\"hello\" />";
    assertEquals(html, output);
  }
View Full Code Here

    String html = "<input type=\"text\" name=\"field\" value=\"hello\" />";
    assertEquals(html, output);
  }

  public void testIdAttrHtml() {
    Widget w = new TextInputWidget();
    String[] value = new String[]{"hello"};
    Map<String, Object> attrs = new LinkedHashMap<String, Object>();
    attrs.put("id", "id_%s");
    String output = w.render("field", value, attrs);
    String html = "<input id=\"id_field\" type=\"text\" name=\"field\" value=\"hello\" />";
    assertEquals(html, output);
  }
View Full Code Here

    String html = "<input type=\"hidden\" name=\"field\" value=\"hello\" />";
    assertEquals(html, output);
  }
 
  public void testHiddenWidgetHtml() {
    Widget w = new HiddenInputWidget();   
    String value = "hello";
    String output = w.render("field", value, new LinkedHashMap<String, Object>());
    String html = "<input type=\"hidden\" name=\"field\" value=\"hello\" />";
    assertEquals(html, output);
  }
View Full Code Here

 
  public void testBaseHtml() {
    Map<String, String> choices = new LinkedHashMap<String, String>();
    choices.put("1", "One");
    choices.put("2", "Two");
    Widget w = new SelectWidget<String, String>().setChoices(choices);
//    ChoiceField field = (ChoiceField) new SelectField(injector.getInstance(WidgetFactory.class)).setChoices(choices).setAllowNull(false);
//    w.setField(field);
    String value = "2";
    String output = w.render("field", value, new HashMap<String, Object>());
    String html = "<select name=\"field\"><option value=\"1\" >One</option><option value=\"2\" selected=\"selected\">Two</option></select>";
    assertEquals(html, output);
  }
View Full Code Here

 
  public void testNullValue() {
    Map<String, String> choices = new LinkedHashMap<String, String>();
    choices.put("1", "One");
    choices.put("2", "Two");
    Widget w = new SelectWidget<String, String>().setChoices(choices);
//    ChoiceField field = (ChoiceField) new SelectField(injector.getInstance(WidgetFactory.class)).setChoices(choices).setAllowNull(false);
//    w.setField(field);
    String value = null;
    String output = w.render("field", value, new HashMap<String, Object>());
    String html = "<select name=\"field\"><option value=\"1\" >One</option><option value=\"2\" >Two</option></select>";
    assertEquals(html, output);
  }
View Full Code Here

TOP

Related Classes of javango.forms.widgets.Widget

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.