Example usage for javax.servlet.jsp.tagext BodyContent clearBody

List of usage examples for javax.servlet.jsp.tagext BodyContent clearBody

Introduction

In this page you can find the example usage for javax.servlet.jsp.tagext BodyContent clearBody.

Prototype


public void clearBody() 

Source Link

Document

Clear the body without throwing any exceptions.

Usage

From source file:net.naijatek.myalumni.util.taglib.BirthdayListTag.java

@Override
public int doAfterBody() throws JspException, JspTagException {
    BodyContent bc = getBodyContent();
    bc.clearBody(); // clean up
    return SKIP_BODY;
}

From source file:net.naijatek.myalumni.util.taglib.DisplayRSSTag.java

@Override
public int doAfterBody() throws JspException, JspTagException {
    //System.out.println("doAfterBody()");
    BodyContent bc = getBodyContent();
    //setTableWidth(bc.getString());  // get body string
    bc.clearBody(); // clean up
    return SKIP_BODY;
}

From source file:net.naijatek.myalumni.util.taglib.BuildImageTag.java

@Override
public int doAfterBody() throws JspException, JspTagException {
    BodyContent bc = getBodyContent();
    setImageUrl(bc.getString()); // get body string
    bc.clearBody(); // clean up
    return SKIP_BODY;
}

From source file:net.mlw.vlh.web.tag.DefaultColumnCheckBoxTag.java

/**
 * @see javax.servlet.jsp.tagext.Tag#doEndTag()
 *//*from w  ww. j  a  va2  s .c  o m*/
public int doEndTag() throws JspException {

    ValueListSpaceTag rootTag = (ValueListSpaceTag) JspUtils.getParent(this, ValueListSpaceTag.class);
    ValueListConfigBean config = rootTag.getConfig();

    DefaultRowTag rowTag = (DefaultRowTag) JspUtils.getParent(this, DefaultRowTag.class);
    appendClassCellAttribute(rowTag.getRowStyleClass());

    Locale locale = config.getLocaleResolver().resolveLocale((HttpServletRequest) pageContext.getRequest());

    if (rowTag.getCurrentRowNumber() == 0) {
        String titleKey = getTitleKey();
        String label = (titleKey == null) ? getTitle()
                : config.getMessageSource().getMessage(titleKey, null, titleKey, locale);

        StringBuffer header = new StringBuffer(512);
        if (label != null) {
            header.append(label);
        }

        header.append(
                "<input type=\"checkbox\" onclick=\"for(i=0; i < this.form.elements.length; i++) {if (this.form.elements[i].name=='")
                .append(getName()).append("') {this.form.elements[i].checked = this.checked;}}\"/>");

        ColumnInfo columnInfo = new ColumnInfo(config.getDisplayHelper().help(pageContext, header.toString()),
                property, null, getAttributes());

        // Process toolTip if any
        // toolTip or toolTipKey is set => get the string and put it into the ColumnInfo
        String toolTipKey = getToolTipKey();
        columnInfo.setToolTip((toolTipKey == null) ? getToolTip()
                : config.getMessageSource().getMessage(toolTipKey, null, toolTipKey, locale));

        rowTag.addColumnInfo(columnInfo);
    }

    Object bean = pageContext.getAttribute(rowTag.getBeanName());
    Object value = "na";

    try {
        value = PropertyUtils.getProperty(bean, property);
    } catch (Exception e) {
    }

    StringBuffer sb = new StringBuffer();

    sb.append(rowTag.getDisplayProvider().getCellPreProcess(getCellAttributes()));

    BodyContent bodyContent = getBodyContent();
    if (bodyContent != null && bodyContent.getString() != null && bodyContent.getString().length() > 0) {
        sb.append(bodyContent.getString());
        bodyContent.clearBody();
    } else {
        sb.append("<input type=\"checkbox\" name=\"").append(name).append("\" value=\"").append(value)
                .append("\"/>");
    }

    sb.append(rowTag.getDisplayProvider().getCellPostProcess());
    JspUtils.write(pageContext, sb.toString());

    release();

    return EVAL_PAGE;
}

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();
            }//from www  .  j  a v  a 2s. c o  m

            // bodyContent??
            this.isPrintBody = true;
        }
    }

    return SKIP_BODY;
}

From source file:com.agiletec.aps.tags.ExecWidgetTag.java

protected void buildWidgetOutput(IPage page, String[] widgetOutput) throws JspException {
    ServletRequest req = this.pageContext.getRequest();
    RequestContext reqCtx = (RequestContext) req.getAttribute(RequestContext.REQCTX);
    try {//from  ww w  . j  av  a2  s.  c  om
        List<IFrameDecoratorContainer> decorators = this.extractDecorators();
        BodyContent body = this.pageContext.pushBody();
        Widget[] widgets = page.getWidgets();
        for (int frame = 0; frame < widgets.length; frame++) {
            reqCtx.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_FRAME, new Integer(frame));
            Widget widget = widgets[frame];
            body.clearBody();
            this.includeWidget(reqCtx, widget, decorators);
            widgetOutput[frame] = body.getString();
        }
    } catch (Throwable t) {
        String msg = "Error detected during widget preprocessing";
        throw new JspException(msg, t);
    }
}

From source file:net.ontopia.topicmaps.nav2.taglibs.logic.ForEachTag.java

/**
 * Actions after some body has been evaluated.
 *//*from  w  ww .  j  a  v  a  2 s  . c  om*/
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.jcreate.e3.table.html.tag.ColumnTag.java

public int doEndTag() throws JspException {
    TableTag tableTag = getTableTag();//from ww w  .  j a  va 2  s  .  c  o  m
    if (tableTag == null) {
        throw new JspException("column  table?");
    }
    boolean isCreatedTable = tableTag.isCreatedTable();
    if (isCreatedTable == false) {//
        return super.doEndTag();
    }

    boolean isCreatedHeader = tableTag.isCreatedHeader();
    if (isCreatedHeader == false) {
        //column
        HTMLColumn column = (HTMLColumn) tableTag.getTable().getColumn(this.property);
        column.setTitle(this.title);
        column.setWidth(this.width);
        column.setHidden(this.hidden);
        column.setAlign(this.align);
        column.setSortable(this.sortable == null ? getDefaultSortable() : this.sortable.booleanValue());
        column.setTitleKey(this.titleKey);
        column.setStyle(this.style);
        column.setStyleClass(this.styleClass);
        column.setHeaderStyle(headerStyle);
        SortInfo sortInfo = tableTag.getSortInfo();
        if (sortInfo != null) {//??
            String sortColumn = sortInfo.getSortProperty();
            if (this.property.equals(sortColumn)) {//??
                column.setSortDir(sortInfo.getSortDir());//??
            }
        }
        column.setSortName(this.sortName);
        ColumnGroupTag groupTag = (ColumnGroupTag) findAncestorWithClass(this, ColumnGroupTag.class);
        if (groupTag != null) {//
            groupTag.addColumn(column);
        }
        /**
         * @todo:column
         */
        return super.doEndTag();
    }

    BodyContent content = this.bodyContent;
    if (content != null) {
        String bodyContext = content.getString();//?body?
        /**
         * @fixme: bodyContent???bodyContent.
         * ???"",.
         * 
         */
        if ("".equals(bodyContext) == false) {
            //??,body context??.?body content.
            //jsp2.0?
            if (((CompositeCellDecorator) currCell.getCellDecorator()).getSize() == 0) {
                JspDecorator jsp = new JspDecorator();
                jsp.setJsp(bodyContext);
                content.clearBody();
                this.addCellDecorator(jsp);
            }
        }
        super.setBodyContent(null);//tomcat5.028?,nulll               
    }

    cleanUp();
    return super.doEndTag();
}

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 ww  w  .  j  a  va 2s . co m
            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.jboss.dashboard.ui.taglib.CheckPermissionTag.java

/**
 * @see javax.servlet.jsp.tagext.BodyTagSupport
 *///from w w w.  j  a v a2 s .c  om
public int doAfterBody() throws JspException {
    BodyContent body = getBodyContent();
    String html = body.getString();
    body.clearBody();

    try {
        boolean hasPerm = getUserStatus().hasPermission(permission);
        if (hasPerm)
            getPreviousOut().print(html);
        return SKIP_BODY;
    } catch (Exception ex) {
        throw new JspException("I/O exception ", ex);
    }
}