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

项目: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;
}
项目:nyla    文件:ConfigTag.java   
/**
 * Write a configuration property indicated in the tag id
 */
public int doStartTag()
   throws JspException
{
    try
    {
        String propName = this.getId();

        Debugger.println(this,"looking for config property id "+propName);

        this.pageContext.getOut().write(Config.getProperty(this.getId(),defaultValue));         
    } 
    catch (IOException e)
    {           
        Debugger.printError(e);

    }
    return BodyTagSupport.SKIP_BODY;
}
项目: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;
}
项目: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;
}
项目: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;
}
项目: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());

}
项目: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");
}
项目: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 "[]";
}
项目: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;

}
项目: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;
}
项目: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();
}
项目: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;
}
项目: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;
}
项目:DMWeb    文件:DMWebFragmentBodyTagLibrary.java   
@Override
public int doEndTag() throws JspException
{
   try
   {
      BodyContent bc = this.getBodyContent();
      String body = bc.getString();
      JspWriter out = this.pageContext.getOut();
      out.println("<body>");
      out.print(body);

      JSONStructure jsonStructure = new JSONStructure(0);
      this.marshaller.marschall(this.serializationData, jsonStructure);
      String json = jsonStructure.toString();

      out.println("<script>\nvar bz_davide_dm_widgets = " + json + "</script>");
      out.println("</body>");
      return BodyTagSupport.EVAL_PAGE;
   }
   catch (Exception exxx)
   {
      throw new JspException(exxx);
   }
}
项目:ehcachetag    文件:CacheTagTest.java   
/**
 * Key is null, check that we return EVAL_BODY_INCLUDE.
 * 
 * @throws JspException
 */
@Test
public void testDoStartTag_null_key() throws JspException {
    // given
    testSubject.setKey(null);
    testSubject.setCache("mycache");

    // when
    int actualResult = testSubject.doStartTag();

    // then
    Assert.assertEquals(BodyTagSupport.EVAL_BODY_INCLUDE, actualResult);

    // verify cleanup
    Assert.assertNull(testSubject.getCache());
    verifyCleanup();
}
项目:ehcachetag    文件:CacheTagTest.java   
/**
 * Cache is null, check that we return EVAL_BODY_INCLUDE.
 * 
 * @throws JspException
 */
@Test
public void testDoStartTag_null_cache() throws JspException {
    // given
    testSubject.setKey("mykey");
    testSubject.setCache(null);
    testSubject.setModifiers("hi");

    // when
    int actualResult = testSubject.doStartTag();

    // then
    Assert.assertEquals(BodyTagSupport.EVAL_BODY_INCLUDE, actualResult);

    verifyCleanup();
}
项目:ehcachetag    文件:CacheTagTest.java   
/**
 * Cache is null, check that we return EVAL_BODY_INCLUDE.
 * Also improves the code coverage by added a HttpServletRequest.
 * 
 * @throws JspException
 */
@Test
public void testDoStartTag_null_cache_httpservletrequest() throws JspException {
    // given
    testSubject.setKey("mykey");
    testSubject.setCache(null);
    testSubject.setModifiers("hi");
    HttpServletRequest servletRequest = Mockito.mock(HttpServletRequest.class);
    Mockito.when(servletRequest.getRequestURI()).thenReturn("http://example.com/testpage.jsp");
    Mockito.when(pageContext.getRequest()).thenReturn(servletRequest);

    // when
    int actualResult = testSubject.doStartTag();

    // then
    Assert.assertEquals(BodyTagSupport.EVAL_BODY_INCLUDE, actualResult);

    verifyCleanup();
}
项目:ehcachetag    文件:CacheTagTest.java   
/**
 * Cache not found.
 * 
 * @throws JspException
 */
@Test
public void testDoStartTag_cache_not_found() throws JspException {
    // given
    testSubject.setKey("mykey");
    testSubject.setCache("mycache");
    testSubject.setModifiers("hi");
    Mockito.when(cacheManager.getEhcache(Mockito.anyString())).thenReturn(null);

    // when
    int actualResult = testSubject.doStartTag();

    // then
    Assert.assertEquals(BodyTagSupport.EVAL_BODY_INCLUDE, actualResult);

    Mockito.verify(cacheManager).getEhcache("mycache");
    verifyCleanup();
}
项目:ehcachetag    文件:CacheTagTest.java   
/**
 * Cache found, but the value with the key is not there.
 * 
 * @throws JspException
 */
@Test
public void testDoStartTag_no_cached_value() throws JspException {
    // given
    testSubject.setKey("mykey");
    testSubject.setCache("mycache");
    Mockito.when(cacheManager.getEhcache(Mockito.anyString())).thenReturn(ehcache);

    // when
    int actualResult = testSubject.doStartTag();

    // then
    Assert.assertEquals(BodyTagSupport.EVAL_BODY_BUFFERED, actualResult);

    Assert.assertEquals("mycache", testSubject.getCache());
    Mockito.verifyNoMoreInteractions(jspWriter);
}
项目:ehcachetag    文件:CacheTagTest.java   
/**
 * We found a cached value
 * 
 * @throws JspException
 * @throws IOException 
 */
@Test
public void testDoStartTag_cached_value() throws JspException, IOException {
    // given
    ensureCacheContent("mycache", "mykey", "cached_content");
    testSubject.setKey("mykey");
    testSubject.setCache("mycache");

    // when
    int actualResult = testSubject.doStartTag();

    // then
    Assert.assertEquals(BodyTagSupport.SKIP_BODY, actualResult);
    Mockito.verify(pageContext).getOut();
    Mockito.verify(jspWriter).write("cached_content");

    Mockito.verifyNoMoreInteractions(jspWriter);
}
项目:ehcachetag    文件:CacheTagTest.java   
@Test
public void testDoStartTag_null_cache_key() {
    // given

    // when
    int actualResult = -1;
    try {
        actualResult = testSubject.doStartTag();
    } catch (JspException e) {
        Assert.fail(e.getMessage());
    }

    // then
    Assert.assertEquals(BodyTagSupport.EVAL_BODY_INCLUDE, actualResult);
    Mockito.verify(pageContext).findAttribute(EHCacheTagConstants.MODIFIER_FACTORY_ATTRIBUTE);
    Mockito.verifyNoMoreInteractions(jspWriter, pageContext);
}
项目:ehcachetag    文件:CacheTagTest.java   
/**
 * Test doStartTag where the first modifier throws an exception
 * @throws JspException 
 */
@Test
public void doStartTag_modifier_not_found() throws JspException {
    // given
    testSubject.setKey("testkey");
    CacheTagModifier modifier = Mockito.mock(CacheTagModifier.class);
    Mockito.doThrow(new RuntimeException()).when(modifier).beforeLookup(Mockito.any(CacheTag.class), Mockito.any(JspContext.class));
    Mockito.when(cacheTagModifierFactory.getCacheTagModifier(Mockito.anyString())).thenReturn(modifier);

    // when
    int actualResult = testSubject.doStartTag();

    // then
    Assert.assertEquals(BodyTagSupport.EVAL_BODY_INCLUDE, actualResult);

    // cleanup
    Assert.assertNull(testSubject.getKey());
    Assert.assertNull(testSubject.getCache());
    Assert.assertEquals("", testSubject.getModifiers());
}
项目:ehcachetag    文件:CacheTagTest.java   
/**
 * Test doStartTag where the first modifier throws an exception
 * @throws JspException 
 */
@Test
public void doStartTag_modifier_exception() throws JspException {
    // given
    testSubject.setKey("testkey");
    CacheTagModifier modifier = Mockito.mock(CacheTagModifier.class);
    Mockito.doThrow(new RuntimeException()).when(modifier).beforeLookup(Mockito.any(CacheTag.class), Mockito.any(JspContext.class));
    Mockito.when(cacheTagModifierFactory.getCacheTagModifier(Mockito.anyString())).thenReturn(modifier);

    // when
    int actualResult = testSubject.doStartTag();

    // then
    Assert.assertEquals(BodyTagSupport.EVAL_BODY_INCLUDE, actualResult);

    verifyCleanup();
}
项目:ontopia    文件:JSPPageExecuter.java   
private void loopTag(TagSupport tag, JSPTreeNodeIF curNode)
  throws JspException, IOException {
  // loop as long as tag says so
  int token;
  do {
    runTag(tag, curNode);
    token = tag.doAfterBody();
  } while (token == BodyTagSupport.EVAL_BODY_AGAIN);
  if (token != BodyTagSupport.SKIP_BODY)
    throw new OntopiaRuntimeException("Internal error: unknown doAfterBody token: " + token);
}
项目:spacewalk    文件: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;
 }
项目:spacewalk    文件: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;
    currentSortDir = fetchSortDir();

    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;
}
项目:spacewalk    文件:ColumnTag.java   
/**
 * Gets the active sort direction for the column, or empty string if the list is not
 * sorted on this column.
 *
 * @return Active sort direction for the column
 */
private String fetchSortDir() {
    String sortName = getSortName();

    ListTag parent = (ListTag) BodyTagSupport.findAncestorWithClass(this,
            ListTag.class);

    if (isAlphaBarSelected() && parent.getAlphaBarColumn().equals(sortName)) {
        return RequestContext.SORT_ASC;
    }

    String requestLabel = pageContext.getRequest().
            getParameter(ListTagUtil.makeSortByLabel(getListName()));

    if (requestLabel != null && !requestLabel.equals(sortName)) {
        return "";
    }

    String sortDirectionKey = ListTagUtil.makeSortDirLabel(getListName());
    String sortDir = pageContext.getRequest().getParameter(sortDirectionKey);

    if (StringUtils.isBlank(sortDir)) {
        sortDir = defaultSortDir;
    }

    return StringUtils.isEmpty(sortDir) ? "" : sortDir;
}
项目:spacewalk    文件: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();
}
项目:spacewalk    文件: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));
}
项目:spacewalk    文件: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);
}
项目:spacewalk    文件: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;
}
项目:spacewalk    文件:ListSetTag.java   
private void verifyEnvironment() throws JspException {
    if (BodyTagSupport.findAncestorWithClass(this, this.getClass()) != null) {
        throw new JspException("ListSet tags may not be nested.");
    }
    if (pageContext.getRequest().getAttribute("parentUrl") == null) {
        throw new JspException("Request attribute 'parentUrl' must be set.");
    }
}
项目:spacewalk    文件:SelectableColumnTag.java   
/**
 * {@inheritDoc}
 */
@Override
public int doEndTag() throws JspException {
    ListCommand command = ListTagUtil.
                                        getCurrentCommand(this, pageContext);
    if (command.equals(ListCommand.RENDER)) {
        ListTagUtil.write(pageContext, "</td>");
    }
    release();
    return BodyTagSupport.EVAL_PAGE;
}
项目:spacewalk    文件:SelectableColumnTag.java   
private boolean isSelected() {
    if (!StringUtils.isBlank(selectExpr)) {
        return selectExpr.equalsIgnoreCase("true");
    }

    ListTag parent = (ListTag)BodyTagSupport.
                    findAncestorWithClass(this, ListTag.class);

    String selectionsKey = ListSessionSetHelper.makeSelectionsName(parent.getName());
    Map selections = (Map)pageContext.getRequest().getAttribute(selectionsKey);

    return selections != null && selections.containsKey(valueExpr);
}
项目:spacewalk    文件:DecoratorTag.java   
/**
 * {@inheritDoc}
 */
public int doEndTag() throws JspException {
    ListCommand command = ListTagUtil.getCurrentCommand(this, pageContext);
    if (command.equals(ListCommand.ENUMERATE)) {
        if (!StringUtils.isBlank(name)) {
            ListTag parent = (ListTag) BodyTagSupport.findAncestorWithClass(this,
                    ListTag.class);
            parent.addDecorator(name);
        }
    }
    return super.doEndTag();
}
项目:spacewalk    文件:ListTag.java   
private int doAfterBodyRenderData() throws JspException {
    // if there was a previous object, close its row
    if (currentObject != null) {
        ListTagUtil.write(pageContext, "</tr>");
    }

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

    if (iterator.hasNext()) {
        Object obj = iterator.next();
        if (RhnListTagFunctions.isExpandable(obj)) {
            parentObject = obj;
        }
        currentObject = obj;
    }
    else {
        currentObject = null;
    }

    if (currentObject != null) {
        ListTagUtil.write(pageContext, "<tr");
        renderRowClassAndId();

        ListTagUtil.write(pageContext, ">");
        pageContext.setAttribute(rowName, currentObject);
    }
    else  {
        return doAfterBodyRenderAfterData();
    }
    return BodyTagSupport.EVAL_BODY_AGAIN;
}
项目:spacewalk    文件:ListTag.java   
/**
 * ${@inheritDoc}
 */
@Override
public int doStartTag() throws JspException {
    verifyEnvironment();
    addDecorator(decoratorName);
    setupPageData();
    setPageSize();
    manip = new DataSetManipulator(pageSize, pageData,
            (HttpServletRequest) pageContext.getRequest(),
            getUniqueName(), isParentAnElement());
    ListTagUtil.setCurrentCommand(pageContext, getUniqueName(),
                ListCommand.ENUMERATE);
    return BodyTagSupport.EVAL_BODY_INCLUDE;
}
项目:spacewalk    文件:RowRendererTag.java   
/**
 * {@inheritDoc}
 */
public int doEndTag() throws JspException {
    ListCommand command = ListTagUtil.getCurrentCommand(this, pageContext);
    if (command.equals(ListCommand.ENUMERATE)) {
        if (!StringUtils.isBlank(name)) {
            ListTag parent = (ListTag) BodyTagSupport.findAncestorWithClass(this,
                    ListTag.class);

            try {
                ClassLoader cl = Thread.currentThread().getContextClassLoader();

                if (name.indexOf('.') == -1) {
                    name = "com.redhat.rhn.frontend.taglibs.list.row." +
                        name;
                }
                RowRenderer row = (RowRenderer) cl.loadClass(name)
                        .newInstance();
                if (!StringUtils.isEmpty(classes)) {
                    row.setRowClasses(classes);
                }
                parent.setRowRenderer(row);

            }
            catch (Exception e) {
                String msg = "Exception while adding Decorator [" + name + "]";
                throw new JspException(msg, e);
            }
        }
    }
    return super.doEndTag();
}
项目:spacewalk    文件:RadioColumnTag.java   
/**
 * {@inheritDoc}
 */
@Override
public int doEndTag() throws JspException {
    ListCommand command = ListTagUtil.
                                        getCurrentCommand(this, pageContext);
    if (command.equals(ListCommand.RENDER)) {
        ListTagUtil.write(pageContext, "</td>");
    }
    release();
    return BodyTagSupport.EVAL_PAGE;
}
项目:spacewalk    文件:ListTagUtil.java   
/**
 * Locates the current ListCommand
 * @param caller tag calling the method
 * @param ctx caller's page context
 * @return ListCommand if found, otherwise null
 */
public static ListCommand getCurrentCommand(Tag caller, PageContext ctx) {
    ListTag parent = null;
    if (!(caller instanceof ListTag)) {
        parent = (ListTag) BodyTagSupport.findAncestorWithClass(caller, ListTag.class);
    }
    else {
        parent = (ListTag) caller;
    }
    if (parent != null) {
        return (ListCommand) ctx.getAttribute(parent.getUniqueName() + "_cmd");
    }
    return null;
}