javax.servlet.jsp.tagext.JspTag#javax.servlet.jsp.tagext.Tag源码实例Demo

下面列出了javax.servlet.jsp.tagext.JspTag#javax.servlet.jsp.tagext.Tag 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: spring4-understanding   文件: MessageTagTests.java
@Test
public void messageTagWithCodeAndArgumentAndNestedArgument() throws JspException {
	PageContext pc = createPageContext();
	final StringBuffer message = new StringBuffer();
	MessageTag tag = new MessageTag() {
		@Override
		protected void writeMessage(String msg) {
			message.append(msg);
		}
	};
	tag.setPageContext(pc);
	tag.setCode("testArgs");
	assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
	tag.setArguments(5);
	tag.addArgument(7);
	assertEquals("Correct doEndTag return value", Tag.EVAL_PAGE, tag.doEndTag());
	assertEquals("Correct message", "test 5 message 7", message.toString());
}
 
源代码2 项目: java-technology-stack   文件: CheckboxTagTests.java
@Test
public void collectionOfPetsAsStringNotSelected() throws Exception {
	this.tag.setPath("pets");
	this.tag.setValue("Santa's Little Helper");

	int result = this.tag.doStartTag();
	assertEquals(Tag.SKIP_BODY, result);

	String output = getOutput();

	// wrap the output so it is valid XML
	output = "<doc>" + output + "</doc>";

	SAXReader reader = new SAXReader();
	Document document = reader.read(new StringReader(output));
	Element checkboxElement = (Element) document.getRootElement().elements().get(0);
	assertEquals("input", checkboxElement.getName());
	assertEquals("checkbox", checkboxElement.attribute("type").getValue());
	assertEquals("pets", checkboxElement.attribute("name").getValue());
	assertNull(checkboxElement.attribute("checked"));
}
 
源代码3 项目: kfs   文件: GroupTitleLineRenderer.java
protected void renderGroupActions(PageContext pageContext, Tag parentTag) throws JspException {
    List<? extends AccountingLineViewActionDefinition> accountingLineGroupActions = accountingLineGroupDefinition.getAccountingLineGroupActions();
    if (!this.isGroupActionsRendered() || accountingLineGroupActions == null || accountingLineGroupActions.isEmpty()) {
        return;
    }

    List<AccountingLineViewAction> viewActions = new ArrayList<AccountingLineViewAction>();
    for (AccountingLineViewActionDefinition action : accountingLineGroupActions) {
        String actionMethod = action.getActionMethod();
        String actionLabel = action.getActionLabel();
        String imageName = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString("externalizable.images.url") + action.getImageName();

        AccountingLineViewAction viewAction = new AccountingLineViewAction(actionMethod, actionLabel, imageName);
        viewActions.add(viewAction);
    }

    if (!viewActions.isEmpty()) {
        ActionsRenderer actionsRenderer = new ActionsRenderer();
        actionsRenderer.setTagBeginning(" ");
        actionsRenderer.setTagEnding(" ");
        actionsRenderer.setPostButtonSpacing(" ");
        actionsRenderer.setActions(viewActions);
        actionsRenderer.render(pageContext, parentTag);
        actionsRenderer.clear();
    }
}
 
源代码4 项目: kfs   文件: DynamicNameLabelRenderer.java
/**
 * 
 * @see org.kuali.kfs.sys.document.web.renderers.Renderer#render(javax.servlet.jsp.PageContext, javax.servlet.jsp.tagext.Tag, org.kuali.rice.krad.bo.BusinessObject)
 */
public void render(PageContext pageContext, Tag parentTag) throws JspException {
    JspWriter out = pageContext.getOut();
    try {
        out.write("<br />");
        out.write("<div id=\""+fieldName+".div\" class=\"fineprint\">");
        if (!StringUtils.isBlank(fieldValue)) {
            out.write(fieldValue);
        }
        out.write("</div>");
        
        if (!StringUtils.isBlank(fieldValue)) {
            renderValuePersistingTag(pageContext, parentTag);
        }
    }
    catch (IOException ioe) {
        throw new JspException("Difficulty rendering a dynamic field label", ioe);
    }
}
 
源代码5 项目: spring-analysis-note   文件: MessageTagTests.java
@Test
public void messageTagWithCodeAndNestedArguments() throws JspException {
	PageContext pc = createPageContext();
	final StringBuffer message = new StringBuffer();
	MessageTag tag = new MessageTag() {
		@Override
		protected void writeMessage(String msg) {
			message.append(msg);
		}
	};
	tag.setPageContext(pc);
	tag.setCode("testArgs");
	assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
	tag.addArgument("arg1");
	tag.addArgument(6);
	assertEquals("Correct doEndTag return value", Tag.EVAL_PAGE, tag.doEndTag());
	assertEquals("Correct message", "test arg1 message 6", message.toString());
}
 
源代码6 项目: spring4-understanding   文件: SelectTagTests.java
@Test
public void multipleExplicitlyFalse() throws Exception {
	this.tag.setPath("name");
	this.tag.setItems(Country.getCountries());
	this.tag.setItemValue("isoCode");
	this.tag.setMultiple("false");
	int result = this.tag.doStartTag();
	assertEquals(Tag.SKIP_BODY, result);

	String output = getOutput();
	output = "<doc>" + output + "</doc>";

	SAXReader reader = new SAXReader();
	Document document = reader.read(new StringReader(output));
	Element rootElement = document.getRootElement();
	assertEquals(1, rootElement.elements().size());

	Element selectElement = rootElement.element("select");
	assertEquals("select", selectElement.getName());
	assertEquals("name", selectElement.attribute("name").getValue());
	assertNull(selectElement.attribute("multiple"));

	List children = selectElement.elements();
	assertEquals("Incorrect number of children", 4, children.size());
}
 
源代码7 项目: logging-log4j2   文件: DumpTagTest.java
@Test
public void testDoEndTagDefaultPageScope() throws Exception {
    this.context.setAttribute("testAttribute01", "testValue01", PageContext.PAGE_SCOPE);
    this.context.setAttribute("anotherAttribute02", "finalValue02", PageContext.PAGE_SCOPE);
    this.context.setAttribute("badAttribute03", "skippedValue03", PageContext.SESSION_SCOPE);

    final int returnValue = this.tag.doEndTag();
    assertEquals("The return value is not correct.", Tag.EVAL_PAGE, returnValue);

    this.writer.flush();
    final String output = new String(this.output.toByteArray(), UTF8);
    assertEquals("The output is not correct.",
            "<dl>" +
                    "<dt><code>testAttribute01</code></dt><dd><code>testValue01</code></dd>" +
                    "<dt><code>anotherAttribute02</code></dt><dd><code>finalValue02</code></dd>" +
                    "</dl>", output);
}
 
源代码8 项目: spring-analysis-note   文件: BindTagTests.java
@Test
public void bindTagWithIndexedProperties() throws JspException {
	PageContext pc = createPageContext();
	IndexedTestBean tb = new IndexedTestBean();
	Errors errors = new ServletRequestDataBinder(tb, "tb").getBindingResult();
	errors.rejectValue("array[0]", "code1", "message1");
	errors.rejectValue("array[0]", "code2", "message2");
	pc.getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "tb", errors);

	BindTag tag = new BindTag();
	tag.setPageContext(pc);
	tag.setPath("tb.array[0]");
	assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
	BindStatus status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
	assertTrue("Has status variable", status != null);
	assertTrue("Correct expression", "array[0]".equals(status.getExpression()));
	assertTrue("Value is TestBean", status.getValue() instanceof TestBean);
	assertTrue("Correct value", "name0".equals(((TestBean) status.getValue()).getName()));
	assertTrue("Correct isError", status.isError());
	assertTrue("Correct errorCodes", status.getErrorCodes().length == 2);
	assertTrue("Correct errorMessages", status.getErrorMessages().length == 2);
	assertTrue("Correct errorCode", "code1".equals(status.getErrorCodes()[0]));
	assertTrue("Correct errorCode", "code2".equals(status.getErrorCodes()[1]));
	assertTrue("Correct errorMessage", "message1".equals(status.getErrorMessages()[0]));
	assertTrue("Correct errorMessage", "message2".equals(status.getErrorMessages()[1]));
}
 
源代码9 项目: spring4-understanding   文件: OptionTagTests.java
@Test
public void withCustomObjectNotSelected() throws Exception {
	String selectName = "testBean.someNumber";
	getPageContext().setAttribute(SelectTag.LIST_VALUE_PAGE_ATTRIBUTE, new BindStatus(getRequestContext(), selectName, false));
	this.tag.setValue(new Float(12.35));
	this.tag.setLabel("GBP 12.35");
	int result = this.tag.doStartTag();
	assertEquals(BodyTag.EVAL_BODY_BUFFERED, result);
	result = this.tag.doEndTag();
	assertEquals(Tag.EVAL_PAGE, result);

	String output = getOutput();

	assertOptionTagOpened(output);
	assertOptionTagClosed(output);
	assertContainsAttribute(output, "value", "12.35");
	assertAttributeNotPresent(output, "selected");
	assertBlockTagContains(output, "GBP 12.35");
}
 
源代码10 项目: spring-analysis-note   文件: RadioButtonTagTests.java
@Test
public void collectionOfPetsNotSelected() throws Exception {
	this.tag.setPath("pets");
	this.tag.setValue(new Pet("Santa's Little Helper"));

	int result = this.tag.doStartTag();
	assertEquals(Tag.SKIP_BODY, result);

	String output = getOutput();

	// wrap the output so it is valid XML
	output = "<doc>" + output + "</doc>";

	SAXReader reader = new SAXReader();
	Document document = reader.read(new StringReader(output));
	Element checkboxElement = (Element) document.getRootElement().elements().get(0);
	assertEquals("input", checkboxElement.getName());
	assertEquals("radio", checkboxElement.attribute("type").getValue());
	assertEquals("pets", checkboxElement.attribute("name").getValue());
	assertEquals("Santa's Little Helper", checkboxElement.attribute("value").getValue());
	assertNull(checkboxElement.attribute("checked"));
}
 
源代码11 项目: logging-log4j2   文件: SetLoggerTagTest.java
@Test
public void testDoEndTagStringVarRequestScope() throws Exception {
    this.tag.setLogger("testDoEndTagStringVarRequestScope");

    this.tag.setVar("goodbyeCruelWorld");
    this.tag.setScope("request");

    assertNull("The default logger should be null.", TagUtils.getDefaultLogger(this.context));
    assertEquals("The return value is not correct.", Tag.EVAL_PAGE, this.tag.doEndTag());
    assertNull("The default logger should still be null.", TagUtils.getDefaultLogger(this.context));

    final Object attribute = this.context.getAttribute("goodbyeCruelWorld", PageContext.REQUEST_SCOPE);
    assertNotNull("The attribute should not be null.", attribute);
    assertTrue("The attribute should be a Log4jTaglibLogger.", attribute instanceof Log4jTaglibLogger);

    final Log4jTaglibLogger logger = (Log4jTaglibLogger)attribute;
    assertEquals("The logger name is not correct.", "testDoEndTagStringVarRequestScope", logger.getName());
}
 
源代码12 项目: uyuni   文件: RequireTagTest.java
public void testMixin() {

        boolean flag = false;
        try {
            rt.setAcl("true_test()");
            rt.setMixins("throws.class.not.found.exception," +
                         BooleanAclHandler.class.getName());

            tth.assertDoStartTag(Tag.EVAL_BODY_INCLUDE);
            flag = true;
        }
        catch (JspException je) {
            assertFalse(flag);
        }
        catch (Exception e) {
            fail(e.toString());
        }
    }
 
源代码13 项目: spring-analysis-note   文件: OptionsTagTests.java
@Test
public void withItemsNullReference() throws Exception {
	getPageContext().setAttribute(
			SelectTag.LIST_VALUE_PAGE_ATTRIBUTE, new BindStatus(getRequestContext(), "testBean.country", false));

	this.tag.setItems(Collections.emptyList());
	this.tag.setItemValue("isoCode");
	this.tag.setItemLabel("name");
	int result = this.tag.doStartTag();
	assertEquals(Tag.SKIP_BODY, result);
	String output = getOutput();
	output = "<doc>" + output + "</doc>";

	SAXReader reader = new SAXReader();
	Document document = reader.read(new StringReader(output));
	Element rootElement = document.getRootElement();

	List children = rootElement.elements();
	assertEquals("Incorrect number of children", 0, children.size());
}
 
源代码14 项目: java-technology-stack   文件: OptionTagTests.java
@Test
public void withCustomObjectNotSelected() throws Exception {
	String selectName = "testBean.someNumber";
	BindStatus bindStatus = new BindStatus(getRequestContext(), selectName, false);
	getPageContext().setAttribute(SelectTag.LIST_VALUE_PAGE_ATTRIBUTE, bindStatus);
	this.tag.setValue(new Float(12.35));
	this.tag.setLabel("GBP 12.35");
	int result = this.tag.doStartTag();
	assertEquals(BodyTag.EVAL_BODY_BUFFERED, result);
	result = this.tag.doEndTag();
	assertEquals(Tag.EVAL_PAGE, result);

	String output = getOutput();

	assertOptionTagOpened(output);
	assertOptionTagClosed(output);
	assertContainsAttribute(output, "value", "12.35");
	assertAttributeNotPresent(output, "selected");
	assertBlockTagContains(output, "GBP 12.35");
}
 
源代码15 项目: java-technology-stack   文件: OptionTagTests.java
@Test
public void canBeDisabledEvenWhenSelected() throws Exception {
	String selectName = "testBean.name";
	BindStatus bindStatus = new BindStatus(getRequestContext(), selectName, false);
	getPageContext().setAttribute(SelectTag.LIST_VALUE_PAGE_ATTRIBUTE, bindStatus);
	this.tag.setValue("bar");
	this.tag.setLabel("Bar");
	this.tag.setDisabled(true);
	int result = this.tag.doStartTag();
	assertEquals(BodyTag.EVAL_BODY_BUFFERED, result);
	result = this.tag.doEndTag();
	assertEquals(Tag.EVAL_PAGE, result);

	String output = getOutput();

	assertOptionTagOpened(output);
	assertOptionTagClosed(output);
	assertContainsAttribute(output, "value", "bar");
	assertContainsAttribute(output, "disabled", "disabled");
	assertBlockTagContains(output, "Bar");
}
 
源代码16 项目: spring-analysis-note   文件: MessageTagTests.java
@Test
public void messageTagWithTextAndHtmlEscapeAndJavaScriptEscape() throws JspException {
	PageContext pc = createPageContext();
	final StringBuffer message = new StringBuffer();
	MessageTag tag = new MessageTag() {
		@Override
		protected void writeMessage(String msg) {
			message.append(msg);
		}
	};
	tag.setPageContext(pc);
	tag.setText("' test & text \\");
	tag.setHtmlEscape(true);
	tag.setJavaScriptEscape(true);
	assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
	assertEquals("Correct doEndTag return value", Tag.EVAL_PAGE, tag.doEndTag());
	assertEquals("Correct message", "&#39; test &amp; text \\\\", message.toString());
}
 
源代码17 项目: logging-log4j2   文件: SetLoggerTagTest.java
@Test
public void testDoEndTagStringVarPageScope() throws Exception {
    this.tag.setLogger("testDoEndTagStringVarPageScope");

    this.tag.setVar("goodbyeCruelWorld");

    assertNull("The default logger should be null.", TagUtils.getDefaultLogger(this.context));
    assertEquals("The return value is not correct.", Tag.EVAL_PAGE, this.tag.doEndTag());
    assertNull("The default logger should still be null.", TagUtils.getDefaultLogger(this.context));

    final Object attribute = this.context.getAttribute("goodbyeCruelWorld", PageContext.PAGE_SCOPE);
    assertNotNull("The attribute should not be null.", attribute);
    assertTrue("The attribute should be a Log4jTaglibLogger.", attribute instanceof Log4jTaglibLogger);

    final Log4jTaglibLogger logger = (Log4jTaglibLogger)attribute;
    assertEquals("The logger name is not correct.", "testDoEndTagStringVarPageScope", logger.getName());
}
 
源代码18 项目: spring4-understanding   文件: MessageTagTests.java
@Test
public void messageTagWithCodeAndObjectArgument() throws JspException {
	PageContext pc = createPageContext();
	final StringBuffer message = new StringBuffer();
	MessageTag tag = new MessageTag() {
		@Override
		protected void writeMessage(String msg) {
			message.append(msg);
		}
	};
	tag.setPageContext(pc);
	tag.setCode("testArgs");
	tag.setArguments(5);
	assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
	assertEquals("Correct doEndTag return value", Tag.EVAL_PAGE, tag.doEndTag());
	assertEquals("Correct message", "test 5 message {1}", message.toString());
}
 
源代码19 项目: java-technology-stack   文件: ErrorsTagTests.java
@Test
public void withExplicitWhitespaceBodyContent() throws Exception {
	this.tag.setBodyContent(new MockBodyContent("\t\n   ", getWriter()));

	// construct an errors instance of the tag
	TestBean target = new TestBean();
	target.setName("Rob Harrop");
	Errors errors = new BeanPropertyBindingResult(target, COMMAND_NAME);
	errors.rejectValue("name", "some.code", "Default Message");

	exposeBindingResult(errors);

	int result = this.tag.doStartTag();
	assertEquals(BodyTag.EVAL_BODY_BUFFERED, result);

	result = this.tag.doEndTag();
	assertEquals(Tag.EVAL_PAGE, result);

	String output = getOutput();
	assertElementTagOpened(output);
	assertElementTagClosed(output);

	assertContainsAttribute(output, "id", "name.errors");
	assertBlockTagContains(output, "Default Message");
}
 
源代码20 项目: spring4-understanding   文件: CheckboxTagTests.java
@Test
public void collectionOfPetsAsStringNotSelected() throws Exception {
	this.tag.setPath("pets");
	this.tag.setValue("Santa's Little Helper");

	int result = this.tag.doStartTag();
	assertEquals(Tag.SKIP_BODY, result);

	String output = getOutput();

	// wrap the output so it is valid XML
	output = "<doc>" + output + "</doc>";

	SAXReader reader = new SAXReader();
	Document document = reader.read(new StringReader(output));
	Element checkboxElement = (Element) document.getRootElement().elements().get(0);
	assertEquals("input", checkboxElement.getName());
	assertEquals("checkbox", checkboxElement.attribute("type").getValue());
	assertEquals("pets", checkboxElement.attribute("name").getValue());
	assertNull(checkboxElement.attribute("checked"));
}
 
源代码21 项目: spring-analysis-note   文件: MessageTagTests.java
@Test
public void messageTagWithCodeAndObjectArgument() throws JspException {
	PageContext pc = createPageContext();
	final StringBuffer message = new StringBuffer();
	MessageTag tag = new MessageTag() {
		@Override
		protected void writeMessage(String msg) {
			message.append(msg);
		}
	};
	tag.setPageContext(pc);
	tag.setCode("testArgs");
	tag.setArguments(5);
	assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
	assertEquals("Correct doEndTag return value", Tag.EVAL_PAGE, tag.doEndTag());
	assertEquals("Correct message", "test 5 message {1}", message.toString());
}
 
源代码22 项目: spacewalk   文件: NavDialogMenuTagTest.java
public void testIOExceptionHandling() {
    TagTestHelper tth = TagTestUtils.setupTagTest(nmt, url);

    boolean exceptionNotThrown = false;

    try {
        // need to override the JspWriter
        RhnMockExceptionJspWriter out = new RhnMockExceptionJspWriter();
        tth.getPageContext().setJspWriter(out);

        // ok let's test the tag
        setupTag(nmt, 10, 4, NAV_XML, DIALOG_NAV);
        tth.assertDoStartTag(Tag.SKIP_BODY);
        exceptionNotThrown = true;
    }
    catch (JspException e) {
        assertFalse(exceptionNotThrown);
    }
}
 
源代码23 项目: kfs   文件: AccountingLineViewField.java
/**
 * Renders a dynamic field label
 *
 * @param pageContext the page context to render to
 * @param parentTag the parent tag requesting this rendering
 * @param accountingLine the line which owns the field being rendered
 * @param accountingLinePropertyPath the path from the form to the accounting line
 */
protected void renderDynamicNameLabel(PageContext pageContext, Tag parentTag, AccountingLineRenderingContext renderingContext) throws JspException {
    AccountingLine accountingLine = renderingContext.getAccountingLine();
    String accountingLinePropertyPath = renderingContext.getAccountingLinePropertyPath();

    DynamicNameLabelRenderer renderer = new DynamicNameLabelRenderer();
    if (definition.getDynamicNameLabelGenerator() != null) {
        renderer.setFieldName(definition.getDynamicNameLabelGenerator().getDynamicNameLabelFieldName(accountingLine, accountingLinePropertyPath));
        renderer.setFieldValue(definition.getDynamicNameLabelGenerator().getDynamicNameLabelValue(accountingLine, accountingLinePropertyPath));
    }
    else {
        if (!StringUtils.isBlank(getField().getPropertyValue())) {
            if (getField().isSecure()) {
                renderer.setFieldValue(getField().getDisplayMask().maskValue(getField().getPropertyValue()));
            }
            else {
                renderer.setFieldValue(getDynamicNameLabelDisplayedValue(accountingLine));
            }
        }
        renderer.setFieldName(accountingLinePropertyPath + "." + definition.getDynamicLabelProperty());
    }
    renderer.render(pageContext, parentTag);
    renderer.clear();
}
 
源代码24 项目: java-technology-stack   文件: MessageTagTests.java
@Test
public void messageTagWithCodeAndArgumentAndNestedArgument() throws JspException {
	PageContext pc = createPageContext();
	final StringBuffer message = new StringBuffer();
	MessageTag tag = new MessageTag() {
		@Override
		protected void writeMessage(String msg) {
			message.append(msg);
		}
	};
	tag.setPageContext(pc);
	tag.setCode("testArgs");
	assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
	tag.setArguments(5);
	tag.addArgument(7);
	assertEquals("Correct doEndTag return value", Tag.EVAL_PAGE, tag.doEndTag());
	assertEquals("Correct message", "test 5 message 7", message.toString());
}
 
源代码25 项目: spring4-understanding   文件: MessageTagTests.java
@Test
public void messageTagWithTextAndJavaScriptEscape() throws JspException {
	PageContext pc = createPageContext();
	final StringBuffer message = new StringBuffer();
	MessageTag tag = new MessageTag() {
		@Override
		protected void writeMessage(String msg) {
			message.append(msg);
		}
	};
	tag.setPageContext(pc);
	tag.setText("' test & text \\");
	tag.setJavaScriptEscape(true);
	assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
	assertEquals("Correct doEndTag return value", Tag.EVAL_PAGE, tag.doEndTag());
	assertEquals("Correct message", "\\' test & text \\\\", message.toString());
}
 
源代码26 项目: spring-analysis-note   文件: OptionTagTests.java
@Test
public void renderSelected() throws Exception {
	String selectName = "testBean.name";
	BindStatus bindStatus = new BindStatus(getRequestContext(), selectName, false);
	getPageContext().setAttribute(SelectTag.LIST_VALUE_PAGE_ATTRIBUTE, bindStatus);
	this.tag.setId("myOption");
	this.tag.setValue("foo");
	this.tag.setLabel("Foo");
	int result = this.tag.doStartTag();
	assertEquals(BodyTag.EVAL_BODY_BUFFERED, result);
	result = this.tag.doEndTag();
	assertEquals(Tag.EVAL_PAGE, result);

	String output = getOutput();

	assertOptionTagOpened(output);
	assertOptionTagClosed(output);
	assertContainsAttribute(output, "id", "myOption");
	assertContainsAttribute(output, "value", "foo");
	assertContainsAttribute(output, "selected", "selected");
	assertBlockTagContains(output, "Foo");
}
 
源代码27 项目: spring-analysis-note   文件: OptionTagTests.java
@Test
public void withNoLabel() throws Exception {
	String selectName = "testBean.name";
	BindStatus bindStatus = new BindStatus(getRequestContext(), selectName, false);
	getPageContext().setAttribute(SelectTag.LIST_VALUE_PAGE_ATTRIBUTE, bindStatus);
	this.tag.setValue("bar");
	this.tag.setCssClass("myClass");
	this.tag.setOnclick("CLICK");
	int result = this.tag.doStartTag();
	assertEquals(BodyTag.EVAL_BODY_BUFFERED, result);
	result = this.tag.doEndTag();
	assertEquals(Tag.EVAL_PAGE, result);

	String output = getOutput();

	assertOptionTagOpened(output);
	assertOptionTagClosed(output);
	assertContainsAttribute(output, "value", "bar");
	assertContainsAttribute(output, "class", "myClass");
	assertContainsAttribute(output, "onclick", "CLICK");
	assertBlockTagContains(output, "bar");
}
 
源代码28 项目: spring-analysis-note   文件: OptionTagTests.java
@Test
public void withCustomObjectSelected() throws Exception {
	String selectName = "testBean.someNumber";
	BindStatus bindStatus = new BindStatus(getRequestContext(), selectName, false);
	getPageContext().setAttribute(SelectTag.LIST_VALUE_PAGE_ATTRIBUTE, bindStatus);
	this.tag.setValue(new Float(12.34));
	this.tag.setLabel("GBP 12.34");
	int result = this.tag.doStartTag();
	assertEquals(BodyTag.EVAL_BODY_BUFFERED, result);
	result = this.tag.doEndTag();
	assertEquals(Tag.EVAL_PAGE, result);

	String output = getOutput();

	assertOptionTagOpened(output);
	assertOptionTagClosed(output);
	assertContainsAttribute(output, "value", "12.34");
	assertContainsAttribute(output, "selected", "selected");
	assertBlockTagContains(output, "GBP 12.34");
}
 
源代码29 项目: spring4-understanding   文件: OptionTagEnumTests.java
@Test
@SuppressWarnings("rawtypes")
public void withJavaEnum() throws Exception {
	GenericBean testBean = new GenericBean();
	testBean.setCustomEnum(CustomEnum.VALUE_1);
	getPageContext().getRequest().setAttribute("testBean", testBean);
	String selectName = "testBean.customEnum";
	getPageContext().setAttribute(SelectTag.LIST_VALUE_PAGE_ATTRIBUTE, new BindStatus(getRequestContext(), selectName, false));

	this.tag.setValue("VALUE_1");

	int result = this.tag.doStartTag();
	assertEquals(BodyTag.EVAL_BODY_BUFFERED, result);
	result = this.tag.doEndTag();
	assertEquals(Tag.EVAL_PAGE, result);

	String output = getWriter().toString();

	assertOptionTagOpened(output);
	assertOptionTagClosed(output);
	assertContainsAttribute(output, "value", "VALUE_1");
	assertContainsAttribute(output, "selected", "selected");
}
 
源代码30 项目: kfs   文件: AccountingLineGroupTag.java
/**
 * @see javax.servlet.jsp.tagext.TagSupport#doStartTag()
 */
@Override
public int doStartTag() throws JspException {
    super.doStartTag();
    final List<RenderableAccountingLineContainer> containers = generateContainersForAllLines();
    group = groupDefinition.createAccountingLineGroup(getDocument(), containers, collectionPropertyName, collectionItemPropertyName, getForm().getDisplayedErrors(), getForm().getDisplayedWarnings(), getForm().getDisplayedInfo(), getForm().getDocumentActions().containsKey(KRADConstants.KUALI_ACTION_CAN_EDIT));
    group.updateDeletabilityOfAllLines();
    if (getParent() instanceof AccountingLinesTag) {
        ((AccountingLinesTag)getParent()).addGroupToRender(group);
        resetTag();
    }
    return Tag.SKIP_BODY;
}