/** * 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(">"); } }
/** * Indicate that the currently open tag should be closed and marked * as a block level element. * <p>Useful when you plan to write additional content in the body * outside the context of the current {@link TagWriter}. */ public void forceBlock() throws JspException { if (currentState().isBlockTag()) { return; // just ignore since we are already in the block } closeTagAndMarkAsBlock(); }
/** * 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(">"); } }
/** * Indicate that the currently open tag should be closed and marked * as a block level element. * <p>Useful when you plan to write additional content in the body * outside the context of the current {@link TagWriter}. */ public void forceBlock() throws JspException { if (currentState().isBlockTag()) { return; // just ignore since we are already in the block } closeTagAndMarkAsBlock(); }
/** * 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("\""); }
/** * 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(); }
/** * 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(">"); } }
/** * Indicate that the currently open tag should be closed and marked * as a block level element. * <p>Useful when you plan to write additional content in the body * outside the context of the current {@link TagWriter}. */ public void forceBlock() throws JspException { if (currentState().isBlockTag()) { return; // just ignore since we are already in the block } closeTagAndMarkAsBlock(); }
/** * 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("\""); }
/** * 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(); }