/** * Create a new instance of the {@link TagWriter} class that writes to * the supplied {@link PageContext}. * @param pageContext the JSP PageContext to obtain the {@link Writer} from */ public TagWriter(PageContext pageContext) { Assert.notNull(pageContext, "PageContext must not be null"); this.writer = new SafeWriter(pageContext); }
/** * Close the current opening tag (if necessary) and appends the * supplied value as inner text. * @throws IllegalStateException if no tag is open */ public void appendValue(String value) throws JspException { if (!inTag()) { throw new IllegalStateException("Cannot write tag value. No open tag available."); } closeTagAndMarkAsBlock(); this.writer.append(value); }
public SafeWriter append(String value) throws JspException { try { getWriterToUse().write(String.valueOf(value)); return this; } catch (IOException ex) { throw new JspException("Unable to write to JspWriter", ex); } }
/** * Close the current tag, allowing to enforce a full closing tag. * <p>Correctly writes an empty tag if no inner text or nested tags * have been written. * @param enforceClosingTag whether a full closing tag should be * rendered in any case, even in case of a non-block tag */ public void endTag(boolean enforceClosingTag) throws JspException { if (!inTag()) { throw new IllegalStateException("Cannot write end of tag. No open tag available."); } boolean renderClosingTag = true; if (!currentState().isBlockTag()) { // Opening tag still needs to be closed... if (enforceClosingTag) { this.writer.append(">"); } else { this.writer.append("/>"); renderClosingTag = false; } } if (renderClosingTag) { this.writer.append("</").append(currentState().getTagName()).append(">"); } this.tagState.pop(); }
/** * Write an HTML attribute with the specified name and value. * <p>Be sure to write all attributes <strong>before</strong> writing * any inner text or nested tags. * @throws IllegalStateException if the opening tag is closed */ public void writeAttribute(String attributeName, String attributeValue) throws JspException { if (currentState().isBlockTag()) { throw new IllegalStateException("Cannot write attributes after opening tag is closed."); } this.writer.append(" ").append(attributeName).append("=\"") .append(attributeValue).append("\""); }
/** * Closes the current opening tag and marks it as a block tag. */ private void closeTagAndMarkAsBlock() throws JspException { if (!currentState().isBlockTag()) { currentState().markAsBlockTag(); this.writer.append(">"); } }
/** * Close the current opening tag (if necessary) and appends the * supplied value as inner text. * @throws IllegalStateException if no tag is open */ public void appendValue(String value) throws JspException { if (!inTag()) { throw new IllegalStateException("Cannot write tag value. No open tag available."); } closeTagAndMarkAsBlock(); this.writer.append(value); }
/** * Start a new tag with the supplied name. Leaves the tag open so * that attributes, inner text or nested tags can be written into it. * @see #endTag() */ public void startTag(String tagName) throws JspException { if (inTag()) { closeTagAndMarkAsBlock(); } push(tagName); this.writer.append("<").append(tagName); }
/** * Create a new instance of the {@link TagWriter} class that writes to * the supplied {@link PageContext}. * @param pageContext the JSP PageContext to obtain the {@link Writer} from */ public TagWriter(PageContext pageContext) { Assert.notNull(pageContext, "PageContext must not be null"); this.writer = new SafeWriter(pageContext); }
public SafeWriter append(String value) throws JspException { try { getWriterToUse().write(String.valueOf(value)); return this; } catch (IOException ex) { throw new JspException("Unable to write to JspWriter", ex); } }
/** * Create a new instance of the {@link TagWriter} class that writes to * the supplied {@link Writer}. * @param writer the {@link Writer} to write tag content to */ public TagWriter(Writer writer) { Assert.notNull(writer, "Writer must not be null"); this.writer = new SafeWriter(writer); }
/** * Close the current tag, allowing to enforce a full closing tag. * <p>Correctly writes an empty tag if no inner text or nested tags * have been written. * @param enforceClosingTag whether a full closing tag should be * rendered in any case, even in case of a non-block tag */ public void endTag(boolean enforceClosingTag) throws JspException { if (!inTag()) { throw new IllegalStateException("Cannot write end of tag. No open tag available."); } boolean renderClosingTag = true; if (!currentState().isBlockTag()) { // Opening tag still needs to be closed... if (enforceClosingTag) { this.writer.append(">"); } else { this.writer.append("/>"); renderClosingTag = false; } } if (renderClosingTag) { this.writer.append("</").append(currentState().getTagName()).append(">"); } this.tagState.pop(); }
/** * Write an HTML attribute with the specified name and value. * <p>Be sure to write all attributes <strong>before</strong> writing * any inner text or nested tags. * @throws IllegalStateException if the opening tag is closed */ public void writeAttribute(String attributeName, String attributeValue) throws JspException { if (currentState().isBlockTag()) { throw new IllegalStateException("Cannot write attributes after opening tag is closed."); } this.writer.append(" ").append(attributeName).append("=\"") .append(attributeValue).append("\""); }
/** * Start a new tag with the supplied name. Leaves the tag open so * that attributes, inner text or nested tags can be written into it. * @see #endTag() */ public void startTag(String tagName) throws JspException { if (inTag()) { closeTagAndMarkAsBlock(); } push(tagName); this.writer.append("<").append(tagName); }
/** * Create a new instance of the {@link TagWriter} class that writes to * the supplied {@link Writer}. * @param writer the {@link Writer} to write tag content to */ public TagWriter(Writer writer) { Assert.notNull(writer, "Writer must not be null"); this.writer = new SafeWriter(writer); }
/** * Closes the current opening tag and marks it as a block tag. */ private void closeTagAndMarkAsBlock() throws JspException { if (!currentState().isBlockTag()) { currentState().markAsBlockTag(); this.writer.append(">"); } }
/** * Close the current tag, allowing to enforce a full closing tag. * <p>Correctly writes an empty tag if no inner text or nested tags * have been written. * @param enforceClosingTag whether a full closing tag should be * rendered in any case, even in case of a non-block tag */ public void endTag(boolean enforceClosingTag) throws JspException { if (!inTag()) { throw new IllegalStateException("Cannot write end of tag. No open tag available."); } boolean renderClosingTag = true; if (!currentState().isBlockTag()) { // Opening tag still needs to be closed... if (enforceClosingTag) { this.writer.append(">"); } else { this.writer.append("/>"); renderClosingTag = false; } } if (renderClosingTag) { this.writer.append("</").append(currentState().getTagName()).append(">"); } this.tagState.pop(); }
/** * Write an HTML attribute with the specified name and value. * <p>Be sure to write all attributes <strong>before</strong> writing * any inner text or nested tags. * @throws IllegalStateException if the opening tag is closed */ public void writeAttribute(String attributeName, String attributeValue) throws JspException { if (currentState().isBlockTag()) { throw new IllegalStateException("Cannot write attributes after opening tag is closed."); } this.writer.append(" ").append(attributeName).append("=\"") .append(attributeValue).append("\""); }
/** * Closes the current opening tag and marks it as a block tag. */ private void closeTagAndMarkAsBlock() throws JspException { if (!currentState().isBlockTag()) { currentState().markAsBlockTag(); this.writer.append(">"); } }
public SafeWriter append(String value) throws JspException { try { getWriterToUse().write(String.valueOf(value)); return this; } catch (IOException ex) { throw new JspException("Unable to write to JspWriter", ex); } }