类javax.servlet.jsp.tagext.BodyTagSupport源码实例Demo

下面列出了怎么用javax.servlet.jsp.tagext.BodyTagSupport的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: uyuni   文件: ConfigChannelTag.java
/**
 * {@inheritDoc}
 */
public int doEndTag() throws JspException {
    StringBuilder result = new StringBuilder();
    if (nolink || id == null) {
        result.append(writeIcon());
        result.append(name);
    }
    else {
        result.append("<a href=\"" +
                    ConfigChannelTag.makeConfigChannelUrl(id) + "\">");
        result.append(writeIcon());
        result.append(StringEscapeUtils.escapeXml(name) + "</a>");
    }
    JspWriter writer = pageContext.getOut();
    try {
        writer.write(result.toString());
    }
    catch (IOException e) {
        throw new JspException(e);
    }
    return BodyTagSupport.SKIP_BODY;
}
 
源代码2 项目: uyuni   文件: ColumnTag.java
/**
 * ${@inheritDoc}
 */
public int doEndTag() throws JspException {
    if (sortable && attributeName == null && sortAttribute == null) {
        throw new JspException("Sortable columns must use either attr or sortAttr");
    }
    checkForBoundsAndAttrs();
    ListCommand command = ListTagUtil.getCurrentCommand(this, pageContext);
    if (command.equals(ListCommand.RENDER)) {
        ListTagUtil.write(pageContext, "</td>");
    }
    else if (command.equals(ListCommand.ENUMERATE) &&
                        !StringUtils.isBlank(filterAttr)) {
        setupColumnFilter();
    }

    return BodyTagSupport.EVAL_PAGE;
}
 
源代码3 项目: uyuni   文件: SelectableColumnTag.java
/**
 * {@inheritDoc}
 */
@Override
public int doStartTag() throws JspException {

    ListCommand command = ListTagUtil.getCurrentCommand(this, pageContext);
    ListTag parent = (ListTag) BodyTagSupport.findAncestorWithClass(this,
            ListTag.class);
    listName = parent.getUniqueName();
    int retval = BodyTagSupport.SKIP_BODY;
    setupRhnSet();
    if (command.equals(ListCommand.ENUMERATE)) {
        parent.addColumn();
        retval = BodyTagSupport.EVAL_PAGE;
    }
    else if (command.equals(ListCommand.COL_HEADER)) {
        renderHeader(parent);
        retval = BodyTagSupport.EVAL_PAGE;
    }
    else if (command.equals(ListCommand.RENDER)) {
        renderCheckbox();
    }
    return retval;
}
 
源代码4 项目: uyuni   文件: SelectableColumnTag.java
private void renderHiddenItem(String listId, String value) throws JspException {
    ListTagUtil.write(pageContext, "<input type=\"hidden\" ");
    ListTagUtil.write(pageContext, "id=\"");
    ListTagUtil.write(pageContext, "list_items_" + listName + "_" + listId);
    String pageItems = ListTagUtil.makePageItemsName(listName);
    ListTag parent = (ListTag)
                BodyTagSupport.findAncestorWithClass(this, ListTag.class);
    if (!parent.isParentAnElement() &&
            RhnListTagFunctions.isExpandable(getCurrent())) {
        pageItems = "parent_" + pageItems;
    }
    ListTagUtil.write(pageContext, "\" name=\"" + pageItems + "\" ");
    ListTagUtil.write(pageContext, "value=\"");
    ListTagUtil.write(pageContext, value);
    ListTagUtil.write(pageContext, "\" />\n");
}
 
源代码5 项目: uyuni   文件: SelectableColumnTag.java
private String getIgnorableParentIds() {
    ListTag parent = (ListTag)
            BodyTagSupport.findAncestorWithClass(this, ListTag.class);
    if (!parent.isParentAnElement()) {
        StringBuilder buf = new StringBuilder();
        for (Object current : parent.getPageData()) {
            if (RhnListTagFunctions.isExpandable(current)) {
                if (buf.length() > 0) {
                    buf.append(",");
                }
                buf.append("'");
                buf.append(makeCheckboxId(listName,
                                    ListTagHelper.getObjectId(current)));
                buf.append("'");
            }
        }
        buf.insert(0, "[");
        buf.append("]");
        return buf.toString();
    }
    return "[]";
}
 
源代码6 项目: uyuni   文件: ListTag.java
private ListDecorator getDecorator(String decName) throws JspException {
    if (decName != null) {
        ClassLoader cl = Thread.currentThread().getContextClassLoader();
        try {
            if (decName.indexOf('.') == -1) {
                decName = "com.redhat.rhn.frontend.taglibs.list.decorators." +
                                                        decName;
            }
            ListDecorator dec = (ListDecorator) cl.loadClass(decName)
                    .newInstance();
            ListSetTag parent = (ListSetTag) BodyTagSupport
                    .findAncestorWithClass(this, ListSetTag.class);
            dec.setEnvironment(pageContext, parent, getUniqueName());
            return dec;
        }
        catch (Exception e) {
            String msg = "Exception while adding Decorator [" + decName + "]";
            throw new JspException(msg, e);
        }
    }
    return null;

}
 
源代码7 项目: uyuni   文件: ListTag.java
/**
 * ${@inheritDoc}
 */
@Override
public int doEndTag() throws JspException {
    // print the hidden fields after the list widget is printed
    // but before the form of the listset is closed.
    ListTagUtil.write(pageContext, String.format(HIDDEN_TEXT,
            ListTagUtil.makeParentIsAnElementLabel(getUniqueName()),
            parentIsElement));

    // here decorators should insert other e.g hidden input fields
    for (ListDecorator dec : getDecorators()) {
        dec.afterList();
    }

    ListTagUtil.write(pageContext, "<!-- END " + getUniqueName() + " -->");
    release();
    return BodyTagSupport.EVAL_PAGE;
}
 
源代码8 项目: uyuni   文件: ListTag.java
private int doAfterBodyRenderBeforeData() throws JspException {
    ListTagUtil.write(pageContext, "</tr>");
    ListTagUtil.write(pageContext, "</thead>");

    ListTagUtil.setCurrentCommand(pageContext, getUniqueName(),
            ListCommand.BEFORE_RENDER);

    if (manip.isListEmpty()) {
        renderEmptyList();
        ListTagUtil.write(pageContext, "</table>");
        // close panel
        ListTagUtil.write(pageContext, "</div>");
        // close list
        ListTagUtil.write(pageContext, "</div>");

        return BodyTagSupport.SKIP_BODY;
    }
    ListTagUtil.write(pageContext, "<tbody>");

    // render first row. The rest will be rendered in subsequent
    // calls to doAfterBody
    return doAfterBodyRenderData();
}
 
源代码9 项目: uyuni   文件: ListTag.java
/**
 * ${@inheritDoc}
 */
@Override
public int doAfterBody() throws JspException {
    int retval = BodyTagSupport.EVAL_BODY_AGAIN;

    ListCommand nextCmd = getNextCommand();

    switch (nextCmd) {
        case TBL_HEADING:    doAfterBodyRenderListBegin(); break;
        case TBL_ADDONS:     doAfterBodyRenderTopAddons(); break;
        case COL_HEADER:     doAfterBodyRenderColHeaders(); break;
        case BEFORE_RENDER:  retval = doAfterBodyRenderBeforeData(); break;
        case RENDER:         retval = doAfterBodyRenderData(); break;
        case AFTER_RENDER:   retval = doAfterBodyRenderAfterData(); break;
        case TBL_FOOTER:     retval = doAfterBodyRenderFooterAddons(); break;
        default: break;
    }
    return retval;
}
 
源代码10 项目: uyuni   文件: RadioColumnTag.java
/**
 * {@inheritDoc}
 */
@Override
public int doStartTag() throws JspException {

    ListCommand command = ListTagUtil.getCurrentCommand(this, pageContext);
    ListTag parent = (ListTag) BodyTagSupport.findAncestorWithClass(this,
            ListTag.class);
    listName = parent.getUniqueName();
    int retval = BodyTagSupport.SKIP_BODY;

    if (command.equals(ListCommand.ENUMERATE)) {
        parent.addColumn();
        renderHiddenField();
        retval = BodyTagSupport.EVAL_PAGE;
    }
    else if (command.equals(ListCommand.COL_HEADER)) {
        renderHeader(parent);
        retval = BodyTagSupport.EVAL_PAGE;
    }
    else if (command.equals(ListCommand.RENDER)) {
        render(valueExpr);
    }
    return retval;
}
 
源代码11 项目: HongsCORE   文件: AuthTag.java
@Override
public int doStartTag() throws JspException {
  try {
    NaviMap nav = NaviMap.getInstance(this.cnf);
    this.ebb = (this.act == null || nav.chkAuth(this.act))
            && (this.rol == null || nav.chkRole(this.rol))
            && (this.men == null || nav.chkRole(this.men));
  } catch ( HongsException ex) {
    throw new JspException(ex);
  }

  if (this.not) {
      this.ebb = !this.ebb;
  }

  if (this.ebb) {
    return BodyTagSupport.EVAL_BODY_BUFFERED;
  } else {
    return BodyTagSupport.SKIP_BODY;
  }
}
 
源代码12 项目: kisso   文件: HasPermissionTag.java
@Override
public int doStartTag() throws JspException {
    // 在标签开始处出发该方法
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
    SSOToken token = SSOHelper.getSSOToken(request);
    // 如果 token 或者 name 为空
    if (token != null && this.getName() != null && !"".equals(this.getName().trim())) {
        boolean result = SSOConfig.getInstance().getAuthorization().isPermitted(token, this.getName());
        if (result) {
            // 权限验证通过
            // 返回此则执行标签body中内容,SKIP_BODY则不执行
            return BodyTagSupport.EVAL_BODY_INCLUDE;
        }
    }
    return BodyTagSupport.SKIP_BODY;
}
 
源代码13 项目: spacewalk   文件: ConfigChannelTag.java
/**
 * {@inheritDoc}
 */
public int doEndTag() throws JspException {
    StringBuilder result = new StringBuilder();
    if (nolink || id == null) {
        result.append(writeIcon());
        result.append(name);
    }
    else {
        result.append("<a href=\"" +
                    ConfigChannelTag.makeConfigChannelUrl(id) + "\">");
        result.append(writeIcon());
        result.append(StringEscapeUtils.escapeXml(name) + "</a>");
    }
    JspWriter writer = pageContext.getOut();
    try {
        writer.write(result.toString());
    }
    catch (IOException e) {
        throw new JspException(e);
    }
    return BodyTagSupport.SKIP_BODY;
}
 
源代码14 项目: spacewalk   文件: ColumnTag.java
/**
 * ${@inheritDoc}
 */
public int doEndTag() throws JspException {
    if (sortable && attributeName == null && sortAttribute == null) {
        throw new JspException("Sortable columns must use either attr or sortAttr");
    }
    checkForBoundsAndAttrs();
    ListCommand command = ListTagUtil.getCurrentCommand(this, pageContext);
    if (command.equals(ListCommand.RENDER)) {
        ListTagUtil.write(pageContext, "</td>");
    }
    else if (command.equals(ListCommand.ENUMERATE) &&
                        !StringUtils.isBlank(filterAttr)) {
        setupColumnFilter();
    }

    return BodyTagSupport.EVAL_PAGE;
}
 
源代码15 项目: spacewalk   文件: SelectableColumnTag.java
/**
 * {@inheritDoc}
 */
@Override
public int doStartTag() throws JspException {

    ListCommand command = ListTagUtil.getCurrentCommand(this, pageContext);
    ListTag parent = (ListTag) BodyTagSupport.findAncestorWithClass(this,
            ListTag.class);
    listName = parent.getUniqueName();
    int retval = BodyTagSupport.SKIP_BODY;
    setupRhnSet();
    if (command.equals(ListCommand.ENUMERATE)) {
        parent.addColumn();
        retval = BodyTagSupport.EVAL_PAGE;
    }
    else if (command.equals(ListCommand.COL_HEADER)) {
        renderHeader(parent);
        retval = BodyTagSupport.EVAL_PAGE;
    }
    else if (command.equals(ListCommand.RENDER)) {
        renderCheckbox();
    }
    return retval;
}
 
源代码16 项目: spacewalk   文件: SelectableColumnTag.java
/**
 * renders
 * //onclick="checkbox_clicked(this, '$rhnSet')"
 *
 */
private String getOnClickScript(String funcName, String boxName) {
    Object current = getCurrent();
    Object parent = getParentObject();
    String childIds = "[]";
    String memberIds = "[]";
    String parentId = "";
    ListTag parentTag = (ListTag)
        BodyTagSupport.findAncestorWithClass(this, ListTag.class);

    if (RhnListTagFunctions.isExpandable(current)) {
        childIds = getChildIds(current);
    }
    else {
        parentId = getParentId(current, parent);
        memberIds = getMemberIds(current, parent);
    }

    return String.format(CHECKBOX_CLICKED_SCRIPT, funcName, boxName,
                        rhnSet,  makeSelectAllCheckboxId(listName),
                        childIds, memberIds, parentId,
                        parentTag.isParentAnElement());

}
 
源代码17 项目: spacewalk   文件: SelectableColumnTag.java
private void renderHiddenItem(String listId, String value) throws JspException {
    ListTagUtil.write(pageContext, "<input type=\"hidden\" ");
    ListTagUtil.write(pageContext, "id=\"");
    ListTagUtil.write(pageContext, "list_items_" + listName + "_" + listId);
    String pageItems = ListTagUtil.makePageItemsName(listName);
    ListTag parent = (ListTag)
                BodyTagSupport.findAncestorWithClass(this, ListTag.class);
    if (!parent.isParentAnElement() &&
            RhnListTagFunctions.isExpandable(getCurrent())) {
        pageItems = "parent_" + pageItems;
    }
    ListTagUtil.write(pageContext, "\" name=\"" + pageItems + "\" ");
    ListTagUtil.write(pageContext, "value=\"");
    ListTagUtil.write(pageContext, value);
    ListTagUtil.write(pageContext, "\" />\n");
}
 
源代码18 项目: spacewalk   文件: SelectableColumnTag.java
private String getIgnorableParentIds() {
    ListTag parent = (ListTag)
            BodyTagSupport.findAncestorWithClass(this, ListTag.class);
    if (!parent.isParentAnElement()) {
        StringBuilder buf = new StringBuilder();
        for (Object current : parent.getPageData()) {
            if (RhnListTagFunctions.isExpandable(current)) {
                if (buf.length() > 0) {
                    buf.append(",");
                }
                buf.append("'");
                buf.append(makeCheckboxId(listName,
                                    ListTagHelper.getObjectId(current)));
                buf.append("'");
            }
        }
        buf.insert(0, "[");
        buf.append("]");
        return buf.toString();
    }
    return "[]";
}
 
源代码19 项目: spacewalk   文件: ListTag.java
private ListDecorator getDecorator(String decName) throws JspException {
    if (decName != null) {
        ClassLoader cl = Thread.currentThread().getContextClassLoader();
        try {
            if (decName.indexOf('.') == -1) {
                decName = "com.redhat.rhn.frontend.taglibs.list.decorators." +
                                                        decName;
            }
            ListDecorator dec = (ListDecorator) cl.loadClass(decName)
                    .newInstance();
            ListSetTag parent = (ListSetTag) BodyTagSupport
                    .findAncestorWithClass(this, ListSetTag.class);
            dec.setEnvironment(pageContext, parent, getUniqueName());
            return dec;
        }
        catch (Exception e) {
            String msg = "Exception while adding Decorator [" + decName + "]";
            throw new JspException(msg, e);
        }
    }
    return null;

}
 
源代码20 项目: spacewalk   文件: ListTag.java
/**
 * ${@inheritDoc}
 */
@Override
public int doEndTag() throws JspException {
    // print the hidden fields after the list widget is printed
    // but before the form of the listset is closed.
    ListTagUtil.write(pageContext, String.format(HIDDEN_TEXT,
            ListTagUtil.makeParentIsAnElementLabel(getUniqueName()),
            parentIsElement));

    // here decorators should insert other e.g hidden input fields
    for (ListDecorator dec : getDecorators()) {
        dec.afterList();
    }

    ListTagUtil.write(pageContext, "<!-- END " + getUniqueName() + " -->");
    release();
    return BodyTagSupport.EVAL_PAGE;
}
 
源代码21 项目: spacewalk   文件: ListTag.java
private int doAfterBodyRenderBeforeData() throws JspException {
    ListTagUtil.write(pageContext, "</tr>");
    ListTagUtil.write(pageContext, "</thead>");

    ListTagUtil.setCurrentCommand(pageContext, getUniqueName(),
            ListCommand.BEFORE_RENDER);

    if (manip.isListEmpty()) {
        renderEmptyList();
        ListTagUtil.write(pageContext, "</table>");
        // close panel
        ListTagUtil.write(pageContext, "</div>");
        // close list
        ListTagUtil.write(pageContext, "</div>");

        return BodyTagSupport.SKIP_BODY;
    }
    ListTagUtil.write(pageContext, "<tbody>");

    // render first row. The rest will be rendered in subsequent
    // calls to doAfterBody
    return doAfterBodyRenderData();
}
 
源代码22 项目: spacewalk   文件: ListTag.java
/**
 * ${@inheritDoc}
 */
@Override
public int doAfterBody() throws JspException {
    int retval = BodyTagSupport.EVAL_BODY_AGAIN;

    ListCommand nextCmd = getNextCommand();

    switch (nextCmd) {
        case TBL_HEADING:    doAfterBodyRenderListBegin(); break;
        case TBL_ADDONS:     doAfterBodyRenderTopAddons(); break;
        case COL_HEADER:     doAfterBodyRenderColHeaders(); break;
        case BEFORE_RENDER:  retval = doAfterBodyRenderBeforeData(); break;
        case RENDER:         retval = doAfterBodyRenderData(); break;
        case AFTER_RENDER:   retval = doAfterBodyRenderAfterData(); break;
        case TBL_FOOTER:     retval = doAfterBodyRenderFooterAddons(); break;
        default: break;
    }
    return retval;
}
 
源代码23 项目: spacewalk   文件: RadioColumnTag.java
/**
 * {@inheritDoc}
 */
@Override
public int doStartTag() throws JspException {

    ListCommand command = ListTagUtil.getCurrentCommand(this, pageContext);
    ListTag parent = (ListTag) BodyTagSupport.findAncestorWithClass(this,
            ListTag.class);
    listName = parent.getUniqueName();
    int retval = BodyTagSupport.SKIP_BODY;

    if (command.equals(ListCommand.ENUMERATE)) {
        parent.addColumn();
        renderHiddenField();
        retval = BodyTagSupport.EVAL_PAGE;
    }
    else if (command.equals(ListCommand.COL_HEADER)) {
        renderHeader(parent);
        retval = BodyTagSupport.EVAL_PAGE;
    }
    else if (command.equals(ListCommand.RENDER)) {
        render(valueExpr);
    }
    return retval;
}
 
源代码24 项目: uyuni   文件: ConfigFileTag.java
/**
  * {@inheritDoc}
  */
 @Override
public int doEndTag() throws JspException {
     StringBuilder result = new StringBuilder();
     if (nolink  || id == null) {
         result.append(writeIcon());
         result.append(StringEscapeUtils.escapeXml(path));
     }
     else {
         String url;
         if (revisionId != null) {
             url = makeConfigFileRevisionUrl(id, revisionId);
         }
         else {
             url = makeConfigFileUrl(id);
         }

         result.append("<a href=\"" + url + "\">");
         result.append(writeIcon());
         result.append(StringEscapeUtils.escapeXml(path) + "</a>");
     }
     JspWriter writer = pageContext.getOut();
     try {
         writer.write(result.toString());
     }
     catch (IOException e) {
         throw new JspException(e);
     }
     return BodyTagSupport.SKIP_BODY;
 }
 
源代码25 项目: uyuni   文件: ColumnTag.java
/**
 * ${@inheritDoc}
 */
public int doStartTag() throws JspException {
    ListCommand command = ListTagUtil.getCurrentCommand(this, pageContext);
    ListTag parent = (ListTag) BodyTagSupport.findAncestorWithClass(this,
            ListTag.class);
    int retval = BodyTagSupport.SKIP_BODY;

    if (command.equals(ListCommand.ENUMERATE)) {
        parent.addColumn();
        retval = BodyTagSupport.EVAL_PAGE;
        if (isSortable()) {
            parent.setSortable(true);
        }
    }
    else if (command.equals(ListCommand.COL_HEADER)) {
        renderHeader();
        retval = BodyTagSupport.EVAL_PAGE;
    }
    else if (command.equals(ListCommand.RENDER)) {
        if (isBound) {
            renderBound();
            retval = BodyTagSupport.SKIP_BODY;
        }
        else {
            renderUnbound();
            retval = BodyTagSupport.EVAL_BODY_INCLUDE;
        }
    }
    return retval;
}
 
源代码26 项目: uyuni   文件: ColumnTag.java
protected void renderUnbound() throws JspException {
    ListTag parent = (ListTag)
        BodyTagSupport.findAncestorWithClass(this, ListTag.class);
    if (attributeName != null) {
        Object bean = parent.getCurrentObject();
        String value = ListTagUtil.getBeanValue(bean, attributeName);
        pageContext.setAttribute("beanValue", value, PageContext.PAGE_SCOPE);
    }
    writeStartingTd();
}
 
源代码27 项目: uyuni   文件: ColumnTag.java
protected void renderBound() throws JspException {
    ListTag parent = (ListTag)
        BodyTagSupport.findAncestorWithClass(this, ListTag.class);
    Object bean = parent.getCurrentObject();
    writeStartingTd();
    ListTagUtil.write(pageContext, ListTagUtil.
                                    getBeanValue(bean, attributeName));
}
 
源代码28 项目: uyuni   文件: ColumnTag.java
/**
 * Gets current sort direction for this column, or empty string if the list is not
 * currently sorted on this column
 *
 * @return Current sort direction for the column
 */
private String getCurrentSortDir() {
    ListTag parent = (ListTag) BodyTagSupport.findAncestorWithClass(this,
            ListTag.class);

    String currSortAttr = parent.getCurrentSortAttr();
    String currSortDir = parent.getCurrentSortDir();

    return currSortAttr.equals(getSortName()) ? currSortDir : "";
}
 
源代码29 项目: uyuni   文件: ColumnTag.java
private void setupColumnFilter() throws JspException {
    ListTag parent = (ListTag)
            BodyTagSupport.findAncestorWithClass(this, ListTag.class);
    String key = headerKey;
    if (!StringUtils.isBlank(filterMessage)) {
        key = filterMessage;
    }
    ColumnFilter f = new ColumnFilter(key, filterAttr);
    parent.setColumnFilter(f);
}
 
源代码30 项目: uyuni   文件: ListSetTag.java
/**
 * {@inheritDoc}
 */
public int doStartTag() throws JspException {
    //if legend was set, process legends
    if (legend != null) {
        setLegends(legend);
    }
    verifyEnvironment();
    startForm();
    return BodyTagSupport.EVAL_BODY_INCLUDE;
}
 
 类所在包
 同包方法