Package javango.forms.widgets

Examples of javango.forms.widgets.Widget.render()


  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);
  }

  public void testNullValueHtml() {
View Full Code Here


  }

  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);
  }
 
  public void testEmptyArrayValueHtml() {
View Full Code Here

  }
 
  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);
  }

  public void testStringHtml() {
View Full Code Here

  }

  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);
  }
 
  public void testStringArrayHtml() {
View Full Code Here

  }
 
  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);
  }

  public void testIdAttrHtml() {
View Full Code Here

  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);
  }
 
  public void testHiddenHtml() {
View Full Code Here

  }
 
  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

    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);
  }
 
  public void testNullValue() {
View Full Code Here

    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);
  }

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

    choices.put("J", "John");
    choices.put("P", "Paul");
    choices.put("G", "George");
    choices.put("R", "Ringo");
    Widget w = new RadioWidget(choices);
    String out = w.render("beatle", new String[] {"J"}, null);
   
    String correct = "<ul>\n" +
        "<li><label><input name=\"beatle\" type=\"radio\" value=\"J\" checked=\"checked\" /> John</label></li>\n" +
        "<li><label><input name=\"beatle\" type=\"radio\" value=\"P\" /> Paul</label></li>\n" +
        "<li><label><input name=\"beatle\" type=\"radio\" value=\"G\" /> George</label></li>\n" +
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.