コード例 #1
0
ファイル: SelectFieldTest.java プロジェクト: stephenh/truss
  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
ファイル: SelectFieldTest.java プロジェクト: stephenh/truss
  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());
  }