/** * Writes the '{@code value}' attribute to the supplied {@link TagWriter}. * Subclasses may choose to override this implementation to control exactly * when the value is written. */ protected void writeValue(TagWriter tagWriter) throws JspException { String valueToUse = (getValue() != null ? getValue() : getDefaultValue()); tagWriter.writeAttribute("value", processFieldValue(getName(), valueToUse, getType())); }
@Override protected int writeTagContent(TagWriter tagWriter) throws JspException { tagWriter.startTag("button"); writeDefaultAttributes(tagWriter); tagWriter.writeAttribute("type", getType()); writeValue(tagWriter); if (isDisabled()) { tagWriter.writeAttribute(DISABLED_ATTRIBUTE, "disabled"); } tagWriter.forceBlock(); this.tagWriter = tagWriter; return EVAL_BODY_INCLUDE; }
@Override protected int writeTagContent(TagWriter tagWriter) throws JspException { tagWriter.startTag("button"); writeDefaultAttributes(tagWriter); tagWriter.writeAttribute("type", getType()); writeValue(tagWriter); if (isDisabled()) { tagWriter.writeAttribute(DISABLED_ATTRIBUTE, "disabled"); } tagWriter.forceBlock(); this.tagWriter = tagWriter; return EVAL_BODY_INCLUDE; }
@Test public void disabled() throws Exception { this.tag.setDisabled(true); this.tag.doStartTag(); this.tag.doEndTag(); String output = getOutput(); assertTagOpened(output); assertTagClosed(output); assertContainsAttribute(output, "disabled", "disabled"); }
@Test public void buttonTag() throws Exception { assertEquals(Tag.EVAL_BODY_INCLUDE, this.tag.doStartTag()); assertEquals(Tag.EVAL_PAGE, this.tag.doEndTag()); String output = getOutput(); assertTagOpened(output); assertTagClosed(output); assertContainsAttribute(output, "id", "My Id"); assertContainsAttribute(output, "name", "My Name"); assertContainsAttribute(output, "type", "submit"); assertContainsAttribute(output, "value", "My Button"); assertAttributeNotPresent(output, "disabled"); }
/** * Writes the '{@code value}' attribute to the supplied {@link TagWriter}. * Subclasses may choose to override this implementation to control exactly * when the value is written. */ protected void writeValue(TagWriter tagWriter) throws JspException { String valueToUse = (getValue() != null ? getValue() : getDefaultValue()); tagWriter.writeAttribute("value", processFieldValue(getName(), valueToUse, getType())); }
@Override protected int writeTagContent(TagWriter tagWriter) throws JspException { tagWriter.startTag("button"); writeDefaultAttributes(tagWriter); tagWriter.writeAttribute("type", getType()); writeValue(tagWriter); if (isDisabled()) { tagWriter.writeAttribute(DISABLED_ATTRIBUTE, "disabled"); } tagWriter.forceBlock(); this.tagWriter = tagWriter; return EVAL_BODY_INCLUDE; }
/** * Writes the '{@code value}' attribute to the supplied {@link TagWriter}. * Subclasses may choose to override this implementation to control exactly * when the value is written. */ protected void writeValue(TagWriter tagWriter) throws JspException { String valueToUse = (getValue() != null ? getValue() : getDefaultValue()); tagWriter.writeAttribute("value", processFieldValue(getName(), valueToUse, getType())); }