List of usage examples for javax.servlet.jsp.tagext BodyContent getReader
public abstract Reader getReader();
From source file:org.apache.myfaces.shared_impl.taglib.UIComponentBodyTagBase.java
/** * TODO: Ignore <!-- --> comments/*from w ww. j a va 2 s . c om*/ */ private boolean isBodyContentEmpty() { BodyContent bodyContent = getBodyContent(); if (bodyContent == null) { return true; } try { Reader reader = bodyContent.getReader(); int c; while ((c = reader.read()) != -1) { if (!Character.isWhitespace((char) c)) { return false; } } return true; } catch (IOException e) { log.error("Error inspecting BodyContent", e); return false; } }
From source file:org.jasig.resourceserver.utils.taglib.JavaScriptMinificationTag.java
@Override public int doAfterBody() throws JspException { final BodyContent bc = this.getBodyContent(); // getJspWriter to output content final JspWriter out = bc.getEnclosingWriter(); boolean scriptWritten = false; // if the portal is currently configured for aggregation, use // YUICompressor to aggregate the javascript contained in the tag if (isCompressionEnabled()) { final Reader bodyReader = bc.getReader(); try {//from w ww. ja va 2 s . c om final JavaScriptCompressor jsCompressor = new JavaScriptCompressor(bodyReader, this.jsErrorReporter); jsCompressor.compress(out, this.lineBreakColumnNumber, this.obfuscate, false, this.preserveAllSemiColons, this.disableOptimizations); scriptWritten = true; } catch (EvaluatorException e) { log.warn("Failed to parse JS data to minify, falling back to non-minified JS.", e); bc.clearBody(); } catch (IOException e) { log.warn("Failed to read or write JS data, falling back to non-minified JS.", e); bc.clearBody(); } } //Handle both compression not working and compression being disabled if (!scriptWritten) { final Reader bodyReader = bc.getReader(); try { IOUtils.copy(bodyReader, out); } catch (IOException e) { throw new JspException("Failed to write JS data to JSP", e); } } return SKIP_BODY; }
From source file:org.theospi.portfolio.help.control.GlossaryTag.java
public int doAfterBody() throws JspException { BodyContent body = getBodyContent(); JspWriter out = body.getEnclosingWriter(); Reader reader = body.getReader(); Set termSet = getTerms();/*from www.j a v a2s . c om*/ GlossaryEntry[] terms = new GlossaryEntry[termSet.size()]; terms = (GlossaryEntry[]) termSet.toArray(terms); try { HelpTagHelper.renderHelp(reader, body.getBufferSize() - body.getRemaining(), out, terms, firstOnly, hover, link); } catch (IOException ioe) { logger.error(ioe.getMessage(), ioe); } finally { body.clearBody(); // Clear for next evaluation } return (SKIP_BODY); }