Package javango.forms

Examples of javango.forms.Form


    m.put("prefix-subject", new String[] {"hello"});
    m.put("prefix-message", new String[] {"Hi there"});
    m.put("prefix-sender", new String[] {"foo@example.com"});
    m.put("prefix-ccMyself", new String[] {"true"});
    m.put("prefix-value", new String[] {"1234"});
    Form f = injector.getInstance(ContactForm.class).bind(m).setPrefix("prefix").setId(null);
    f.isValid();   
    List<String> expected = new ArrayList<String>();
    expected.add("<input type=\"text\" name=\"prefix-subject\" value=\"hello\" />");
    expected.add("<input type=\"text\" name=\"prefix-message\" value=\"Hi there\" />");
    expected.add("<input type=\"text\" name=\"prefix-sender\" value=\"foo@example.com\" />");
    expected.add("<input type=\"checkbox\" name=\"prefix-ccMyself\" checked=\"checked\" />");
View Full Code Here


      super(factory);
    }     
  }
 
  public void testUnboundErrors() throws Exception {
    Form f = injector.getInstance(ContactForm.class);
    assertFalse(f.isValid());
    Map l = f.getErrors();
    assertNotNull(l);
    assertEquals(l.size(), 0);
  }
View Full Code Here

//
//    assertEquals(expected, form.asTable());
  }
 
  public void testNotEditable() throws Exception {
    Form form = injector.getInstance(TestForm.class);
    form.getFields().get("pickme").setEditable(false);
    form.getFields().get("selectme").setEditable(false);
   
    String expected =
        "<tr><th><label for='id_pickme'>Pickme</label></th><td><input id=\"id_pickme\" type=\"checkbox\" name=\"pickme\" disabled=\"disabled\" /></td></tr>\n" +
        "<tr><th><label for='id_selectme'>Selectme</label></th><td><select id=\"id_selectme\" name=\"selectme\" disabled=\"disabled\"><option value=\"\" >--</option><option value=\"Y\" >Yes</option><option value=\"N\" >No</option></select></td></tr>\n";

    assertEquals(expected, form.asTable());   
  }
View Full Code Here

      language = new SelectField(widgetFactory).setChoices(choices).setWidget(new RadioWidget());
      init();
    }
  }
  public void testRadioField() throws Exception {
    Form f = new FrameworkForm(
        injector.getInstance(FieldFactory.class), injector.getInstance(WidgetFactory.class))
        .setId(null);
   
    String output1 = "<ul>\n" +
        "<li><label><input name=\"language\" type=\"radio\" value=\"P\" /> Python</label></li>\n" +
        "<li><label><input name=\"language\" type=\"radio\" value=\"J\" /> Java</label></li>\n" +
        "</ul>";
    assertEquals(output1, f.get("language").toString());

    String output2 = "<tr><th>Name</th><td><input type=\"text\" name=\"name\" /></td></tr>\n" +
        "<tr><th>Language</th><td><ul>\n" +
        "<li><label><input name=\"language\" type=\"radio\" value=\"P\" /> Python</label></li>\n" +
        "<li><label><input name=\"language\" type=\"radio\" value=\"J\" /> Java</label></li>\n" +
        "</ul></td></tr>\n";
   
    assertEquals(output2, f.asTable());
  }
View Full Code Here

   
    assertEquals(output2, f.asTable());
  }

  public void testRadioFieldId() throws Exception {
    Form f = new FrameworkForm(
        injector.getInstance(FieldFactory.class), injector.getInstance(WidgetFactory.class))
        .setId("id_%s");
   
    String output1 = "<ul>\n" +
        "<li><label for='id_language_0'><input id=\"id_language_0\" name=\"language\" type=\"radio\" value=\"P\" /> Python</label></li>\n" +
        "<li><label for='id_language_1'><input id=\"id_language_1\" name=\"language\" type=\"radio\" value=\"J\" /> Java</label></li>\n" +
        "</ul>";
    assertEquals(output1, f.get("language").toString());

    // TODO The label in the th for labguage should be id_language_0 to point to the first radio button
    String output2 = "<tr><th><label for='id_name'>Name</label></th><td><input id=\"id_name\" type=\"text\" name=\"name\" /></td></tr>\n" +
        "<tr><th><label for='id_language'>Language</label></th><td><ul>\n" +
        "<li><label for='id_language_0'><input id=\"id_language_0\" name=\"language\" type=\"radio\" value=\"P\" /> Python</label></li>\n" +
        "<li><label for='id_language_1'><input id=\"id_language_1\" name=\"language\" type=\"radio\" value=\"J\" /> Java</label></li>\n" +
        "</ul></td></tr>\n";
   
    assertEquals(output2, f.asTable());
  }
View Full Code Here

    m.put("prefix-subject", new String[] {"hello"});
    m.put("prefix-message", new String[] {"Hi there"});
    m.put("prefix-sender", new String[] {"foo@example.com"});
    m.put("prefix-ccMyself", new String[] {"true"});
    m.put("prefix-value", new String[] {"qwer"});
    Form f = injector.getInstance(ContactForm.class).bind(m).setPrefix("prefix").setId(null);
    f.isValid();
    String expected = "<tr><th>Subject</th><td><input type=\"text\" name=\"prefix-subject\" value=\"hello\" /></td></tr>\n" +
        "<tr><th>Message</th><td><input type=\"text\" name=\"prefix-message\" value=\"Hi there\" /></td></tr>\n" +
        "<tr><th>Sender</th><td><input type=\"text\" name=\"prefix-sender\" value=\"foo@example.com\" /></td></tr>\n" +
        "<tr><th>Cc Myself</th><td><input type=\"checkbox\" name=\"prefix-ccMyself\" checked=\"checked\" /></td></tr>\n" +
        "<tr><th>Value</th><td><ul class=\"errorlist\"><li>Integer number not valid</li></ul><input type=\"text\" name=\"prefix-value\" value=\"qwer\" /></td></tr>\n";
    assertEquals(expected, f.asTable());
  }
View Full Code Here

    m.put("prefix-subject", new String[] {"hello"});
    m.put("prefix-message", new String[] {"Hi there"});
    m.put("prefix-sender", new String[] {"foo@example.com"});
    m.put("prefix-ccMyself", new String[] {"true"});
    m.put("prefix-value", new String[] {"1234"});
    Form f = injector.getInstance(ContactForm.class).bind(m).setPrefix("prefix").setId(null);
    f.isValid();
    String expected = "<tr><th>Subject</th><td><input type=\"text\" name=\"prefix-subject\" value=\"hello\" /></td></tr>\n" +
        "<tr><th>Message</th><td><input type=\"text\" name=\"prefix-message\" value=\"Hi there\" /></td></tr>\n" +
        "<tr><th>Sender</th><td><input type=\"text\" name=\"prefix-sender\" value=\"foo@example.com\" /></td></tr>\n" +
        "<tr><th>Cc Myself</th><td><input type=\"checkbox\" name=\"prefix-ccMyself\" checked=\"checked\" /></td></tr>\n" +
        "<tr><th>Value</th><td><input type=\"text\" name=\"prefix-value\" value=\"1234\" /></td></tr>\n";
    assertEquals(expected, f.asTable());
  }
View Full Code Here

    m.put("prefix-subject", new String[] {"hello"});
    m.put("prefix-message", new String[] {"Hi there"});
    m.put("prefix-sender", new String[] {"foo@example.com"});
    m.put("prefix-ccMyself", new String[] {"true"});
    m.put("prefix-value", new String[] {"1234"});
    Form f = injector.getInstance(ContactForm.class).bind(m).setPrefix("prefix");
    assertTrue(f.isValid());
   
    assertEquals("hello", f.getCleanedData().get("subject"));
    assertEquals("Hi there", f.getCleanedData().get("message"));
    assertEquals("foo@example.com", f.getCleanedData().get("sender"));
    assertEquals(Boolean.TRUE, (Boolean)f.getCleanedData().get("ccMyself"));
    assertEquals(new Long(1234), f.getCleanedData().get("value"));
  }
View Full Code Here

    Map<String, String[]> m = new HashMap<String, String[]>();
    m.put("message", new String[] {"Hi there"});
    m.put("sender", new String[] {"foo@example.com"});
    m.put("ccMyself", new String[] {"true"});
    m.put("value", new String[] {"1234"});
    Form f = injector.getInstance(ContactForm.class).bind(m);
    assertTrue(f.isValid());
  }
View Full Code Here

    m.put("subject", new String[] {"123456789"});
    m.put("message", new String[] {"Hi there"});
    m.put("sender", new String[] {"foo@example.com"});
    m.put("ccMyself", new String[] {"true"});
    m.put("value", new String[] {"1234"});
    Form f = injector.getInstance(ContactForm.class).bind(m);
    assertTrue(f.isValid());
   
    m = new HashMap<String, String[]>();
    m.put("subject", new String[] {"123456789012345"});
    m.put("message", new String[] {"Hi there"});
    m.put("sender", new String[] {"foo@example.com"});
    m.put("ccMyself", new String[] {"true"});
    m.put("value", new String[] {"1234"});
    f = injector.getInstance(ContactForm.class).bind(m);
    assertFalse(f.isValid());
    Map errors = f.getErrors();
    assertTrue(errors.containsKey("subject"));
  }
View Full Code Here

TOP

Related Classes of javango.forms.Form

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.