コード例 #1
0
  @Test
  public void testFullSelection() throws Exception {
    tester.startPage(
        new FormTestPage(
            new ComponentBuilder() {

              public Component buildComponent(String id) {
                return new IntegerTable(id, true);
              }
            }));
    tester.assertComponent("form:panel", IntegerTable.class);
    IntegerTable table = (IntegerTable) tester.getComponentFromLastRenderedPage("form:panel");

    // check the select all check and the row check are there
    String selectAllPath = "form:panel:listContainer:selectAllContainer:selectAll";
    String selectFirstPath = "form:panel:listContainer:items:1:selectItemContainer:selectItem";
    tester.assertComponent(selectAllPath, CheckBox.class);
    tester.assertComponent(selectFirstPath, CheckBox.class);

    // test full selection
    assertEquals(0, table.getSelection().size());
    FormTester ft = tester.newFormTester("form");
    ft.setValue("panel:listContainer:selectAllContainer:selectAll", "true");
    tester.executeAjaxEvent(selectAllPath, "onclick");
    assertEquals(10, table.getSelection().size());
    assertEquals(new Integer(0), table.getSelection().get(0));

    // reset selection
    table.setSelection(false);
    assertEquals(0, table.getSelection().size());
  }
コード例 #2
0
  @Test
  public void testSingleSelection() throws Exception {
    tester.startPage(
        new FormTestPage(
            new ComponentBuilder() {

              public Component buildComponent(String id) {
                return new IntegerTable(id, true);
              }
            }));
    tester.assertComponent("form:panel", IntegerTable.class);
    IntegerTable table = (IntegerTable) tester.getComponentFromLastRenderedPage("form:panel");
    assertEquals(0, table.getSelection().size());

    // select just one
    FormTester ft = tester.newFormTester("form");
    ft.setValue("panel:listContainer:items:1:selectItemContainer:selectItem", "true");
    ft.setValue("panel:listContainer:items:7:selectItemContainer:selectItem", "true");
    ft.submit();
    assertEquals(2, table.getSelection().size());
    assertEquals(new Integer(0), table.getSelection().get(0));
    assertEquals(new Integer(6), table.getSelection().get(1));
  }
コード例 #3
0
  @Test
  public void testSingleSelectionByObjectAndIndex() throws Exception {
    tester.startPage(
        new FormTestPage(
            new ComponentBuilder() {

              public Component buildComponent(String id) {
                return new IntegerTable(id, true);
              }
            }));
    tester.assertComponent("form:panel", IntegerTable.class);

    IntegerTable table = (IntegerTable) tester.getComponentFromLastRenderedPage("form:panel");
    assertEquals(0, table.getSelection().size());

    table.selectObject(new Integer(5));
    assertEquals(1, table.getSelection().size());
    assertEquals(new Integer(5), table.getSelection().get(0));

    table.selectObject(7);
    assertEquals(2, table.getSelection().size());
    assertEquals(new Integer(5), table.getSelection().get(0));
    assertEquals(new Integer(7), table.getSelection().get(1));
  }