Package javango.forms

Examples of javango.forms.Form


        "<input type=\"hidden\" name=\"hiddenField\" value=\"hidden value\" />\n</td></tr>\n";
    assertEquals(expected, f.asTable());
  }
 
  public void testReadonly() throws Exception {
    Form f = injector.getInstance(ContactForm.class);
    f.getFields().get("sender").setEditable(false);
    f.getFields().get("cost").setEditable(false);
    String expected = "<tr><th><label for='id_subject'>Subject</label></th><td><input id=\"id_subject\" type=\"text\" name=\"subject\" /></td></tr>\n" +
        "<tr><th><label for='id_message'>Message</label></th><td><input id=\"id_message\" type=\"text\" name=\"message\" /></td></tr>\n" +
        "<tr><th><label for='id_sender'>Sender</label></th><td><input id=\"id_sender\" readonly=\"readonly\" type=\"text\" name=\"sender\" /></td></tr>\n" +
        "<tr><th><label for='id_cost'>Cost</label></th><td><input id=\"id_cost\" readonly=\"readonly\" type=\"text\" name=\"cost\" /></td></tr>\n" +
        "<tr><th><label for='id_ccMyself'>Carbon Copy Myself</label></th><td><input id=\"id_ccMyself\" type=\"checkbox\" name=\"ccMyself\" /></td></tr>\n" +
        "<tr><th><label for='id_value'>The Value</label></th><td><input id=\"id_value\" type=\"text\" name=\"value\" />" +
        "<input id=\"id_hiddenField\" type=\"hidden\" name=\"hiddenField\" />\n</td></tr>\n";
    assertEquals(expected, f.asTable());
  }
View Full Code Here


        "<input id=\"id_hiddenField\" type=\"hidden\" name=\"hiddenField\" />\n</td></tr>\n";
    assertEquals(expected, f.asTable());
  }

  public void testMaxlength() throws Exception {
    Form f = injector.getInstance(ContactForm.class);
    ((CharField)f.getFields().get("message")).setMaxLength(20);
    String expected = "<tr><th><label for='id_subject'>Subject</label></th><td><input id=\"id_subject\" type=\"text\" name=\"subject\" /></td></tr>\n" +
        "<tr><th><label for='id_message'>Message</label></th><td><input maxlength=\"20\" id=\"id_message\" type=\"text\" name=\"message\" /></td></tr>\n" +
        "<tr><th><label for='id_sender'>Sender</label></th><td><input id=\"id_sender\" type=\"text\" name=\"sender\" /></td></tr>\n" +
        "<tr><th><label for='id_cost'>Cost</label></th><td><input id=\"id_cost\" type=\"text\" name=\"cost\" /></td></tr>\n" +
        "<tr><th><label for='id_ccMyself'>Carbon Copy Myself</label></th><td><input id=\"id_ccMyself\" type=\"checkbox\" name=\"ccMyself\" /></td></tr>\n" +
        "<tr><th><label for='id_value'>The Value</label></th><td><input id=\"id_value\" type=\"text\" name=\"value\" />" +
        "<input id=\"id_hiddenField\" type=\"hidden\" name=\"hiddenField\" />\n</td></tr>\n";
    assertEquals(expected, f.asTable());
  }
View Full Code Here

        "<input id=\"id_hiddenField\" type=\"hidden\" name=\"hiddenField\" />\n</td></tr>\n";
    assertEquals(expected, f.asTable());
  }
 
  public void testTemplateAttrs() throws Exception {
    Form f = injector.getInstance(ContactForm.class);
    ((CharField)f.getFields().get("message")).setMaxLength(20);
    String expected = "<input maxlength=\"20\" size=\"20\" something=\"else\" id=\"id_message\" type=\"text\" name=\"message\" />";
    assertEquals(expected, f.get("message").withAttrs("size=20, something=else"));
  }
View Full Code Here

    String expected = "<input maxlength=\"20\" size=\"20\" something=\"else\" id=\"id_message\" type=\"text\" name=\"message\" />";
    assertEquals(expected, f.get("message").withAttrs("size=20, something=else"));
  }
 
  public void testInitial() throws Exception {
    Form f = injector.getInstance(ContactForm.class);
    f.getInitial().put("message", "myvalue");
    String expected = "<input id=\"id_message\" type=\"text\" name=\"message\" value=\"myvalue\" />";
    assertEquals(expected, f.get("message").toString());
  }
View Full Code Here

    String expected = "<input id=\"id_message\" type=\"text\" name=\"message\" value=\"myvalue\" />";
    assertEquals(expected, f.get("message").toString());
  }
 
  public void testInitialQuoted() throws Exception {
    Form f = injector.getInstance(ContactForm.class);
    f.getInitial().put("message", "\"myvalue\"");
    String expected = "<input id=\"id_message\" type=\"text\" name=\"message\" value=\"&quot;myvalue&quot;\" />";
    assertEquals(expected, f.get("message").toString());
  }
View Full Code Here

    m.put("sender", new String[] {"foo@example.com"});
    m.put("cost", new String[] {"1.23"});
    m.put("ccMyself", new String[] {"true"});
    m.put("phoneNumber", new String[] {"111-222-3333"});
    m.put("value", new String[] {"1234"});
    Form f = injector.getInstance(PhoneContactForm.class).bind(m).setId(null);
    f.isValid();
    String expected = "<tr><th>Phone Number</th><td><input type=\"text\" name=\"phoneNumber\" value=\"111-222-3333\" /></td></tr>\n" +
        "<tr><th>Subject</th><td><input type=\"text\" name=\"subject\" value=\"hello\" /></td></tr>\n" +
        "<tr><th>Message</th><td><input type=\"text\" name=\"message\" value=\"Hi there\" /></td></tr>\n" +
        "<tr><th>Sender</th><td><input type=\"text\" name=\"sender\" value=\"foo@example.com\" /></td></tr>\n" +
        "<tr><th>Cost</th><td><input type=\"text\" name=\"cost\" value=\"1.23\" /></td></tr>\n" +
        "<tr><th>Carbon Copy Myself</th><td><input type=\"checkbox\" name=\"ccMyself\" checked=\"checked\" /></td></tr>\n" +
        "<tr><th>The Value</th><td><input type=\"text\" name=\"value\" value=\"1234\" />" +
        "<input type=\"hidden\" name=\"hiddenField\" />\n</td></tr>\n";
    assertEquals(expected, f.asTable());
  }
View Full Code Here

    m.put("sender", new String[] {"foo@example.com"});
    m.put("cost", new String[] {"1.23"});
    m.put("ccMyself", new String[] {"true"});
    m.put("phoneNumber", new String[] {"111-222-3333"});
    m.put("value", new String[] {"1234"});
    Form f = injector.getInstance(PhoneContactFormWithCss.class).bind(m).setId(null);
    f.isValid();
    String expected = "<tr class=\"required\"><th>Phone Number</th><td><input class=\"required\" type=\"text\" name=\"phoneNumber\" value=\"111-222-3333\" /></td></tr>\n" +
        "<tr class=\"error required\"><th>Subject</th><td><ul class=\"errorlist\"><li>This field is required.</li></ul><input class=\"error required\" type=\"text\" name=\"subject\" /></td></tr>\n" +
        "<tr class=\"required\"><th>Message</th><td><input class=\"required\" type=\"text\" name=\"message\" value=\"Hi there\" /></td></tr>\n" +
        "<tr class=\"required\"><th>Sender</th><td><input class=\"required\" type=\"text\" name=\"sender\" value=\"foo@example.com\" /></td></tr>\n" +
        "<tr class=\"required\"><th>Cost</th><td><input class=\"required\" type=\"text\" name=\"cost\" value=\"1.23\" /></td></tr>\n" +
        "<tr class=\"required\"><th>Carbon Copy Myself</th><td><input class=\"required\" type=\"checkbox\" name=\"ccMyself\" checked=\"checked\" /></td></tr>\n" +
        "<tr class=\"required\"><th>The Value</th><td><input class=\"required\" type=\"text\" name=\"value\" value=\"1234\" />" +
        "<input type=\"hidden\" name=\"hiddenField\" />\n</td></tr>\n";
    assertEquals(expected, f.asTable());
  }
View Full Code Here

    m.put("sender", new String[] {"foo@example.com"});
    m.put("cost", new String[] {"1.23"});
    m.put("ccMyself", new String[] {"true"});
    m.put("phoneNumber", new String[] {"111-222-3333"});
    m.put("value", new String[] {"1234"});
    Form f = injector.getInstance(PhoneContactForm.class).bind(m).setId(null);
    f.isValid();
    String expected = "<tr class=\"myRequiredClass\"><th>Phone Number</th><td><input class=\"myRequiredClass\" type=\"text\" name=\"phoneNumber\" value=\"111-222-3333\" /></td></tr>\n" +
        "<tr class=\"myErrorClass myRequiredClass\"><th>Subject</th><td><ul class=\"errorlist\"><li>This field is required.</li></ul><input class=\"myErrorClass myRequiredClass\" type=\"text\" name=\"subject\" /></td></tr>\n" +
        "<tr class=\"myRequiredClass\"><th>Message</th><td><input class=\"myRequiredClass\" type=\"text\" name=\"message\" value=\"Hi there\" /></td></tr>\n" +
        "<tr class=\"myRequiredClass\"><th>Sender</th><td><input class=\"myRequiredClass\" type=\"text\" name=\"sender\" value=\"foo@example.com\" /></td></tr>\n" +
        "<tr class=\"myRequiredClass\"><th>Cost</th><td><input class=\"myRequiredClass\" type=\"text\" name=\"cost\" value=\"1.23\" /></td></tr>\n" +
        "<tr class=\"myRequiredClass\"><th>Carbon Copy Myself</th><td><input class=\"myRequiredClass\" type=\"checkbox\" name=\"ccMyself\" checked=\"checked\" /></td></tr>\n" +
        "<tr class=\"myRequiredClass\"><th>The Value</th><td><input class=\"myRequiredClass\" type=\"text\" name=\"value\" value=\"1234\" />" +
        "<input type=\"hidden\" name=\"hiddenField\" />\n</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[] {"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\" />The subject of the message</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 = "<input type=\"text\" name=\"prefix-subject\" value=\"hello\" />";   
    assertEquals(expected, f.get("subject").toString());
  }
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.