Пример #1
0
  public void testSimpleIntegerWithValueWorkaround() throws Exception {
    TestAction testAction = (TestAction) action;

    IdName hello = new IdName(new Integer(1), "hello");
    IdName world = new IdName(new Integer(2), "world");
    List list2 = new ArrayList();
    list2.add(hello);
    list2.add(world);
    testAction.setList2(list2);

    testAction.setFooInt(new Integer(1));

    SelectTag tag = new SelectTag();
    tag.setPageContext(pageContext);
    tag.setEmptyOption("true");
    tag.setLabel("mylabel");
    tag.setName("fooInt");
    tag.setList("list2");
    tag.setListKey("id");
    tag.setListValue("name");
    tag.setValue("fooInt.toString()");

    // header stuff
    tag.setHeaderKey("headerKey");
    tag.setHeaderValue("headerValue");

    // empty option
    tag.setEmptyOption("true");

    tag.doStartTag();
    tag.doEndTag();

    verify(SelectTag.class.getResource("Select-11.txt"));
  }
Пример #2
0
  public void testExtended() throws Exception {
    TestAction testAction = (TestAction) action;
    testAction.setFoo("hello");
    testAction.setList(
        new String[][] {
          {"hello", "world"},
          {"foo", "bar"}
        });

    SelectTag tag = new SelectTag();
    tag.setPageContext(pageContext);
    tag.setEmptyOption("true");
    tag.setLabel("mylabel");
    tag.setName("foo");
    tag.setList("list");
    tag.setListKey("top[0]");
    tag.setListValue("%{top[0] + ' - ' + top[1]}");

    // header stuff
    tag.setHeaderKey("headerKey");
    tag.setHeaderValue("%{foo + ': headerValue'}");

    // empty option
    tag.setEmptyOption("true");

    tag.doStartTag();
    tag.doEndTag();

    verify(SelectTag.class.getResource("Select-7.txt"));
  }
Пример #3
0
  public void testSimpleWithNulls() throws Exception {
    TestAction testAction = (TestAction) action;
    testAction.setFoo("hello");
    testAction.setList(
        new String[][] {
          {"hello", null},
          {null, "bar"}
        });

    SelectTag tag = new SelectTag();
    tag.setPageContext(pageContext);
    tag.setEmptyOption("true");
    tag.setLabel("mylabel");
    tag.setName("foo");
    tag.setList("list");
    tag.setListKey("top[0]");
    tag.setListValue("top[1]");

    // header stuff
    tag.setHeaderKey("headerKey");
    tag.setHeaderValue("headerValue");

    // empty option
    tag.setEmptyOption("true");

    tag.doStartTag();
    tag.doEndTag();

    verify(SelectTag.class.getResource("Select-9.txt"));
  }
Пример #4
0
  public void testHeaderCanBePreselected() throws Exception {
    SelectTag tag = new SelectTag();
    tag.setPageContext(pageContext);
    tag.setLabel("myLabel");
    tag.setList("#{1:'Cat',2:'Dog'}");
    tag.setName("myPet");
    tag.setHeaderKey("-1");
    tag.setHeaderValue("--- Please Select ---");
    tag.setValue("%{'-1'}");

    tag.doStartTag();
    tag.doEndTag();

    verify(SelectTag.class.getResource("Select-8.txt"));
  }