예제 #1
0
  public void testOptionsTakesABinding() {
    Page p = new Page();
    p.employees = Copy.list(new Employee(2), new Employee(3));

    PageBinding b = new PageBinding(p);
    SelectField<Employee> s =
        new SelectField<Employee>(b.employee()).id("employee").options(b.employees());

    Assert.assertEquals(2, s.getOptionsPossiblyFromBinding().size());
    Assert.assertEquals(2, s.getOptionsPossiblyFromBinding().get(0).id.intValue());
    Assert.assertEquals(3, s.getOptionsPossiblyFromBinding().get(1).id.intValue());
  }
예제 #2
0
  public void testMultiple() {
    this.request.setParameter("employee", "2", "3");

    Page p = new Page();
    PageBinding b = new PageBinding(p);
    SelectField<Employee> s =
        new SelectField<Employee>(b.employees())
            .id("employee")
            .options(new Employee(2))
            .multiple(true);
    s.onProcess();
    Assert.assertEquals(2, p.employees.get(0).id.intValue());
    Assert.assertEquals(3, p.employees.get(1).id.intValue());
  }