List of usage examples for javax.servlet.jsp.tagext BodyContent getEnclosingWriter
public JspWriter getEnclosingWriter()
From source file:com.steeleforge.aem.ironsites.wcm.taglib.SetModeTag.java
@Override public int doAfterBody() throws JspException { BodyContent bc = getBodyContent(); try {/* w w w .java2s . c o m*/ bc.getEnclosingWriter().print(bc.getString()); } catch (IOException ioe) { LOG.debug(ioe.getMessage()); throw new JspException(ioe); } finally { bc = null; } return SKIP_BODY; }
From source file:com.steeleforge.aem.ironsites.xss.taglib.XSSFilterHTMLTag.java
@Override public int doAfterBody() throws JspException { BodyContent bodyContent; String body;// w w w . j a va2 s . com JspWriter out; try { bodyContent = getBodyContent(); out = bodyContent.getEnclosingWriter(); body = XSSUtil.filterHTML(getPolicy(), getContext(), bodyContent.getString(), pageContext); if (StringUtils.isNotEmpty(body)) { out.print(body); } } catch (IOException ioe) { LOG.debug(ioe.getMessage()); throw new JspException(ioe); } finally { bodyContent = null; body = null; out = null; } return SKIP_BODY; }
From source file:com.googlecode.jtiger.modules.ecside.tag.form.ECSideFormTag.java
public int doAfterBody() { BodyContent body = getBodyContent(); try {// w ww . jav a 2 s . c o m JspWriter out = body.getEnclosingWriter(); String bodytext = body.getString(); if ((beansValues != null) && (beansValues.size() > 0)) { bodytext = populateForm(bodytext, beansValues); } out.print(bodytext); } catch (Exception ex) { LogHandler.errorLog(logger, ex); } return SKIP_BODY; }
From source file:com.ultrapower.eoms.common.plugin.ecside.tag.form.ECSideFormTag.java
@Override public int doAfterBody() { BodyContent body = getBodyContent(); try {//from ww w.java2s .c om JspWriter out = body.getEnclosingWriter(); String bodytext = body.getString(); if ((beansValues != null) && (beansValues.size() > 0)) { bodytext = populateForm(bodytext, beansValues); } out.print(bodytext); } catch (Exception ex) { LogHandler.errorLog(logger, ex); } return SKIP_BODY; }
From source file:jp.co.golorp.emarf.tag.lib.BodyTagSupport.java
@Override public int doAfterBody() throws JspException { // bodyContent??? BodyContent bodyContent = this.bodyContent; if (bodyContent != null) { String text = bodyContent.getString(); if (StringUtils.isNotBlank(text)) { try { bodyContent.getEnclosingWriter().print(text); } catch (IOException e) { throw new JspException(e); } finally { bodyContent.clearBody(); }/*w w w . ja va 2 s . com*/ // bodyContent?? this.isPrintBody = true; } } return SKIP_BODY; }
From source file:com.googlecode.psiprobe.jsp.VisualScoreTag.java
public int doAfterBody() throws JspException { BodyContent bc = getBodyContent(); String body = bc.getString().trim(); StringBuffer buf = calculateSuffix(body); try {/*from w ww. j av a 2 s. c o m*/ JspWriter out = bc.getEnclosingWriter(); out.print(buf.toString()); } catch (IOException ioe) { throw new JspException("Error:IOException while writing to client" + ioe.getMessage()); } return SKIP_BODY; }
From source file:net.ontopia.topicmaps.nav2.taglibs.logic.ForEachTag.java
/** * Actions after some body has been evaluated. *///w w w. j a va2s . co m public int doAfterBody() throws JspTagException { // put out the evaluated body BodyContent body = getBodyContent(); JspWriter out = body.getEnclosingWriter(); try { out.print(body.getString()); } catch (IOException ioe) { throw new NavigatorRuntimeException("Error in ForEachTag.", ioe); } // Clear for next evaluation body.clearBody(); //log.debug("doAfterBody, itemsSize: " + items.length + ", index: " + index); // test if we have to repeat the body if (index < items.length && index < maxNumber) { // insert separating string if (separator != null) { try { out.print(separator); } catch (IOException ioe) { throw new NavigatorRuntimeException("Error in ForEachTag.", ioe); } } // set to next value in set setVariableValues(items[index]); index++; return EVAL_BODY_AGAIN; } else { return SKIP_BODY; } }
From source file:net.testdriven.psiprobe.jsp.VisualScoreTag.java
@Override public int doAfterBody() throws JspException { if (value < minValue) { log.info("value " + value + " is less than min value " + minValue); value = minValue;//from w w w. j av a2s . c om } if (value > maxValue) { log.info("value " + value + " is greater than max value " + maxValue); value = maxValue; } if (value + value2 < minValue || value2 < 0) { log.info("value2 " + value2 + " is less than min value"); value2 = 0; } if (value + value2 > maxValue) { log.info("value2 " + value2 + " is greater than max value"); value2 = maxValue - value; } double unitSize = (maxValue - minValue) / (fullBlocks * partialBlocks); double blockWidth = unitSize * partialBlocks; int fullRedBlockCount = (int) Math.floor(value / blockWidth); int partialRedBlockIndex = (int) Math.floor((value - fullRedBlockCount * blockWidth) / unitSize); int partialBlueBlockIndex1 = (partialRedBlockIndex > 0 ? Math.min((int) Math.floor(value2 / unitSize), partialBlocks - partialRedBlockIndex) : 0); int fullBlueBlockCount = Math.max(0, (int) Math.floor(value2 / blockWidth) - (partialRedBlockIndex > 0 ? 1 : 0)); int partialBlueBlockIndex2 = (int) Math.floor( (value2 - (fullBlueBlockCount * blockWidth) - (partialBlueBlockIndex1 * unitSize)) / unitSize); BodyContent bc = getBodyContent(); String body = bc.getString().trim(); StringBuilder buf = new StringBuilder(); // Beginning if (showA) { String format = "a0"; if (fullRedBlockCount > 0 || partialRedBlockIndex > 0) { format = "a1"; } else if (partialBlueBlockIndex1 == 0 && (fullBlueBlockCount > 0 || partialBlueBlockIndex2 > 0)) { format = "a2"; } buf.append(MessageFormat.format(body, new Object[] { format })); } // Full red blocks String fullRedBody = MessageFormat.format(body, partialBlocks + "+0"); for (int i = 0; i < fullRedBlockCount; i++) { buf.append(fullRedBody); } // Mixed red/blue block (mid-block transition) if (partialRedBlockIndex > 0) { String partialBody = MessageFormat.format(body, partialRedBlockIndex + "+" + partialBlueBlockIndex1); buf.append(partialBody); } // Full blue blocks String fullBlueBody = MessageFormat.format(body, "0+" + partialBlocks); for (int i = 0; i < fullBlueBlockCount; i++) { buf.append(fullBlueBody); } // Partial blue block if (partialBlueBlockIndex2 > 0) { String partialBody = MessageFormat.format(body, "0+" + partialBlueBlockIndex2); buf.append(partialBody); } // Empty blocks int emptyBlocks = showEmptyBlocks ? fullBlocks - (fullRedBlockCount + fullBlueBlockCount + (partialRedBlockIndex > 0 ? 1 : 0) + (partialBlueBlockIndex2 > 0 ? 1 : 0)) : 0; if (emptyBlocks > 0) { String emptyBody = MessageFormat.format(body, "0+0"); for (int i = 0; i < emptyBlocks; i++) { buf.append(emptyBody); } } // End if (showB) { String format = "b0"; if (fullRedBlockCount == fullBlocks) { format = "b1"; } else if (fullRedBlockCount + (partialRedBlockIndex + partialBlueBlockIndex1 == partialBlocks ? 1 : 0) + fullBlueBlockCount == fullBlocks) { format = "b2"; } buf.append(MessageFormat.format(body, new Object[] { format })); } try { JspWriter out = bc.getEnclosingWriter(); out.print(buf.toString()); } catch (IOException ioe) { throw new JspException("Error:IOException while writing to client" + ioe.getMessage()); } return SKIP_BODY; }
From source file:org.ecside.tag.form.ECSideFormTag.java
public int doAfterBody() { BodyContent body = getBodyContent(); try {// ww w.j a v a2 s . com JspWriter out = body.getEnclosingWriter(); String bodytext = body.getString(); if ((beansValues != null) && (beansValues.size() > 0)) { bodytext = populateForm(bodytext, beansValues); } out.print(bodytext); } catch (Exception ex) { LogHandler.errorLog(logger, ex); } return SKIP_BODY; }
From source file:org.j2free.jsp.tags.FragmentCacheTag.java
/** * Write the content to the apge, try to acquire lock and update, release lock, * then return SKIP_BODY when complete//from w w w . ja v a2 s.co m * @return * @throws JspException */ @Override public int doAfterBody() throws JspException { // Get the BodyContent, the result of the processing of the body of the tag BodyContent body = getBodyContent(); String content = body.getString(); // Make sure we had a cache if (fragment != null) { // Update the Fragment, doing this before writing to the page will release waiting threads sooner. if (!disable) { if (fragment.tryUpdateAndRelease(content, condition)) log.trace(key + ": UPDATE and RELEASED"); else if (log.isTraceEnabled()) log.warn(key + ": UPDATE FAILED [cache.contains(\"" + key + "\")=" + cache.contains(key) + "]"); } else if (log.isTraceEnabled()) log.trace(key + ": DISABLED, not caching"); } // Attempt to write the body to the page try { if (log.isTraceEnabled()) log.trace(key + ": WRITE OUTPUT"); body.getEnclosingWriter().write(content); } catch (IOException e) { log.error(key, e); } logDuration("COMPUTE"); return SKIP_BODY; }