/** {@inheritDoc} */ public int doEndTag() throws JspException { ListCommand command = (ListCommand) 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(); }
private void setupFilterUI() throws JspException { ListTagUtil.write(pageContext, "<div class=\"filter-input\"><table"); ListTagUtil.write(pageContext, " cellspacing=\"0\""); ListTagUtil.write(pageContext, " cellpadding=\"0\""); if (width != null) { ListTagUtil.write(pageContext, " width=\""); ListTagUtil.write(pageContext, width); ListTagUtil.write(pageContext, "\""); } else { ListTagUtil.write(pageContext, " width=\"100%\""); } ListTagUtil.write(pageContext, ">"); ListTagUtil.write(pageContext, "<tr>"); }
private void renderEmptyList() throws JspException { ListTagUtil.write(pageContext, "<tr class=\"list-row-odd\"><td "); ListTagUtil.write(pageContext, "class=\"first-column last-column\" "); ListTagUtil.write(pageContext, "colspan=\""); ListTagUtil.write(pageContext, String.valueOf(columnCount)); ListTagUtil.write(pageContext, "\">"); if (emptyKey != null) { LocalizationService ls = LocalizationService.getInstance(); String msg = ls.getMessage(emptyKey); ListTagUtil.write(pageContext, "<div class=\"list-empty-message\">"); ListTagUtil.write(pageContext, msg); ListTagUtil.write(pageContext, "<br /></div>"); } ListTagUtil.write(pageContext, "</td></tr>"); }
private void setState() { ListCommand cmd = ListTagUtil.getCurrentCommand(this, pageContext); if (cmd.equals(ListCommand.ENUMERATE)) { haveColsEnumerated = true; } else if (cmd.equals(ListCommand.TBL_HEADER)) { haveTblHeadersRendered = true; } else if (cmd.equals(ListCommand.COL_HEADER)) { haveColHeadersRendered = true; } else if (cmd.equals(ListCommand.TBL_FOOTER)) { haveTblFootersRendered = true; } }
private void renderRowClassAndId() throws JspException { rowCounter++; ListTagUtil.write(pageContext, " class=\""); ListTagUtil.write(pageContext, getRowRenderer().getRowClass(getCurrentObject())); if (rowCounter == manip.findAlphaPosition() % pageSize) { ListTagUtil.write(pageContext, " alphaResult"); } ListTagUtil.write(pageContext, "\" "); if (getCurrentObject() != null) { // if we're rendering a non-item row (e.g. reflink) ListTagUtil.write(pageContext, "id=\""); ListTagUtil.write( pageContext, getRowRenderer().getRowId(getUniqueName(), getCurrentObject())); ListTagUtil.write(pageContext, "\" "); String style = getRowRenderer().getRowStyle(getCurrentObject()); if (!StringUtils.isBlank(style)) { ListTagUtil.write(pageContext, "style=\""); ListTagUtil.write(pageContext, style); ListTagUtil.write(pageContext, "\" "); } } }
/** ${@inheritDoc} */ public int doStartTag() throws JspException { verifyEnvironment(); addDecorator(decoratorName); setupPageData(); setPageSize(); manip = new DataSetManipulator( pageSize, pageData, (HttpServletRequest) pageContext.getRequest(), getUniqueName(), isParentAnElement(), searchParent, searchChild); int retval = BodyTagSupport.EVAL_BODY_INCLUDE; emitId(); ListTagUtil.setCurrentCommand(pageContext, getUniqueName(), ListCommand.ENUMERATE); return retval; }
/** @param searchChildIn The searchChild to set. */ public void setSearchchild(String searchChildIn) { searchChild = ListTagUtil.toBoolean(searchChildIn); }
/** * if set to true, the parent in a tree setup will be considered as an element by itself * * @param value true or false */ public void setParentiselement(String value) { parentIsElement = ListTagUtil.toBoolean(value); }
/** * if set to true, the page numbers at the top and bottom of the list will not be displayed * * @param value true or false */ public void setHidepagenums(String value) { hidePageNums = ListTagUtil.toBoolean(value); }
/** @param searchParentIn The searchParent to set. */ public void setSearchparent(String searchParentIn) { searchParent = ListTagUtil.toBoolean(searchParentIn); }
private void renderPaginationControls(boolean isFooter) throws JspException { if (isFooter && (isEmpty() || hidePageNums)) { return; } if (isFooter) { ListTagUtil.write(pageContext, "<div>"); ListTagUtil.write(pageContext, "<table "); ListTagUtil.write(pageContext, " cellspacing=\"0\" "); ListTagUtil.write(pageContext, "cellpadding=\"0\" width=\"100%\">"); ListTagUtil.write(pageContext, "<tr>"); ListTagUtil.write(pageContext, "<td align=\"left\">"); for (ListDecorator dec : getDecorators()) { dec.afterList(); } ListTagUtil.write(pageContext, "</td>"); } ListTagUtil.write(pageContext, "<td valign=\"middle\" class=\"list-infotext\">"); if (!isEmpty() && !hidePageNums) { ListTagUtil.write(pageContext, manip.getPaginationMessage()); } if (!manip.isListEmpty()) { for (ListDecorator dec : getDecorators()) { if (isFooter) { dec.afterBottomPagination(); dec.setCurrentList(null); } else { dec.afterTopPagination(); } } } ListTagUtil.write(pageContext, " "); ListTagUtil.renderPaginationLinks(pageContext, PAGINATION_NAMES, manip.getPaginationLinks()); ListTagUtil.write(pageContext, "</td>"); ListTagUtil.write(pageContext, "</tr>"); ListTagUtil.write(pageContext, "</table></div>"); }
private void startTable() throws JspException { ListTagUtil.write(pageContext, "<table"); ListTagUtil.write(pageContext, " cellspacing=\"0\""); ListTagUtil.write(pageContext, " cellpadding=\"0\""); if (styleClass != null) { ListTagUtil.write(pageContext, " class=\""); ListTagUtil.write(pageContext, styleClass); ListTagUtil.write(pageContext, "\""); } ListTagUtil.write(pageContext, " id=\""); ListTagUtil.write(pageContext, getStyleId()); ListTagUtil.write(pageContext, "\""); if (width != null) { ListTagUtil.write(pageContext, " width=\""); ListTagUtil.write(pageContext, width); ListTagUtil.write(pageContext, "\""); } ListTagUtil.write(pageContext, ">"); }
private void emitId() throws JspException { ListTagUtil.write(pageContext, "<!-- List id "); ListTagUtil.write(pageContext, getUniqueName()); ListTagUtil.write(pageContext, " -->\n"); }
private void setupManipulator() throws JspException { manip.setAlphaColumn(alphaBarColumn); manip.filter(filter, pageContext); if (!StringUtils.isBlank(ListTagHelper.getFilterValue(pageContext.getRequest(), uniqueName))) { LocalizationService ls = LocalizationService.getInstance(); ListTagUtil.write(pageContext, "<div class=\"site-info\">"); if (manip.getTotalDataSetSize() != manip.getUnfilteredDataSize()) { if (manip.getAllData().size() == 0) { ListTagUtil.write( pageContext, ls.getMessage( "listtag.filteredmessageempty", new Integer(manip.getTotalDataSetSize()))); } else { ListTagUtil.write( pageContext, ls.getMessage("listtag.filteredmessage", new Integer(manip.getTotalDataSetSize()))); } ListTagUtil.write(pageContext, "<br /><a href=\""); List<String> excludeParams = new ArrayList<String>(); excludeParams.add(ListTagUtil.makeSelectActionName(getUniqueName())); excludeParams.add(ListTagUtil.makeFilterByLabel(getUniqueName())); excludeParams.add(ListTagUtil.makeFilterValueByLabel(getUniqueName())); excludeParams.add(ListTagUtil.makeOldFilterValueByLabel(getUniqueName())); excludeParams.add(ListTagUtil.makeFilterSearchChildLabel(getUniqueName())); excludeParams.add(ListTagUtil.makeFilterSearchParentLabel(getUniqueName())); excludeParams.add(ListTagUtil.makeParentIsAnElementLabel(getUniqueName())); ListTagUtil.write( pageContext, ListTagUtil.makeParamsLink( pageContext.getRequest(), name, Collections.EMPTY_MAP, excludeParams)); ListTagUtil.write(pageContext, "\">" + ls.getMessage("listtag.clearfilter")); ListTagUtil.write( pageContext, ls.getMessage("listtag.seeall", new Integer(manip.getUnfilteredDataSize()))); ListTagUtil.write(pageContext, "</a>"); } else { ListTagUtil.write( pageContext, ls.getMessage( "listtag.all_items_in_filter", ListTagHelper.getFilterValue(pageContext.getRequest(), uniqueName))); } ListTagUtil.write(pageContext, "</div>"); } }
/** ${@inheritDoc} */ public int doAfterBody() throws JspException { int retval = BodyTagSupport.EVAL_BODY_AGAIN; ListCommand cmd = ListTagUtil.getCurrentCommand(this, pageContext); boolean haveRenderedColumnHeaderEndTag = false; if (cmd.equals(ListCommand.COL_HEADER)) { ListTagUtil.write(pageContext, "</tr></thead><tbody>"); haveRenderedColumnHeaderEndTag = true; } setState(); if (haveColsEnumerated && !haveTblHeadersRendered) { setupManipulator(); manip.sort(); pageData = manip.getPage(); if (!manip.isListEmpty() && !StringUtils.isBlank(alphaBarColumn)) { AlphaBarHelper.getInstance() .writeAlphaBar(pageContext, manip.getAlphaBarIndex(), getUniqueName()); } for (ListDecorator dec : getDecorators()) { dec.setCurrentList(this); dec.beforeList(); } ListTagUtil.write( pageContext, String.format( HIDDEN_TEXT, ListTagUtil.makeFilterSearchParentLabel(uniqueName), searchParent)); ListTagUtil.write( pageContext, String.format( HIDDEN_TEXT, ListTagUtil.makeFilterSearchChildLabel(uniqueName), searchChild)); ListTagUtil.write( pageContext, String.format( HIDDEN_TEXT, ListTagUtil.makeParentIsAnElementLabel(uniqueName), parentIsElement)); setupFilterUI(); if (filter != null && manip.getUnfilteredDataSize() != 0) { ListTagUtil.renderFilterUI( pageContext, filter, getUniqueName(), width, columnCount, searchParent, searchChild); } if (isSortable()) { String sortByLabel = ListTagUtil.makeSortByLabel(getUniqueName()); String sortDirLabel = ListTagUtil.makeSortDirLabel(getUniqueName()); HtmlTag sortByInputTag = new HtmlTag("input"); sortByInputTag.setAttribute("type", "hidden"); sortByInputTag.setAttribute("name", sortByLabel); sortByInputTag.setAttribute("id", ListTagUtil.makeSortById(getUniqueName())); sortByInputTag.setAttribute( "value", StringUtils.defaultString(pageContext.getRequest().getParameter(sortByLabel))); HtmlTag sortByDirTag = new HtmlTag("input"); sortByDirTag.setAttribute("type", "hidden"); sortByDirTag.setAttribute("name", sortDirLabel); sortByDirTag.setAttribute("id", ListTagUtil.makeSortDirId(getUniqueName())); sortByDirTag.setAttribute( "value", StringUtils.defaultString(pageContext.getRequest().getParameter(sortDirLabel))); ListTagUtil.write(pageContext, sortByInputTag.render()); ListTagUtil.write(pageContext, sortByDirTag.render()); } if (!isEmpty()) { for (ListDecorator dec : getDecorators()) { dec.beforeTopPagination(); } } renderPaginationControls(false); startTable(); HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); manip.bindPaginationInfo(); request.setAttribute("dataSize", String.valueOf(pageData.size() + 1)); ListTagUtil.setCurrentCommand(pageContext, getUniqueName(), ListCommand.TBL_HEADER); if (pageData != null && pageData.size() > 0) { iterator = pageData.iterator(); } else { iterator = null; } } if (haveColsEnumerated && haveTblHeadersRendered && !haveColHeadersRendered) { ListTagUtil.setCurrentCommand(pageContext, getUniqueName(), ListCommand.COL_HEADER); ListTagUtil.write(pageContext, "<thead><tr>"); if (!StringUtils.isBlank(title)) { HtmlTag th = new HtmlTag("th"); th.setAttribute("colspan", String.valueOf(getColumnCount())); HtmlTag strong = new HtmlTag("strong"); strong.addBody(title); th.addBody(strong.render()); ListTagUtil.write(pageContext, th.render()); ListTagUtil.write(pageContext, "</tr>\n<tr>"); } } if (haveColHeadersRendered && !haveTblFootersRendered) { if (!haveRenderedColumnHeaderEndTag) { ListTagUtil.write(pageContext, "</tr>"); } if (manip.isListEmpty()) { renderEmptyList(); return BodyTagSupport.SKIP_BODY; } else { 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, "</tbody>"); ListTagUtil.setCurrentCommand(pageContext, getUniqueName(), ListCommand.TBL_FOOTER); } else { ListTagUtil.write(pageContext, "<tr"); renderRowClassAndId(); ListTagUtil.write(pageContext, ">"); pageContext.setAttribute(rowName, currentObject); } } } else if (haveTblFootersRendered) { retval = BodyTagSupport.SKIP_BODY; } return retval; }
/** ${@inheritDoc} */ public int doEndTag() throws JspException { /* If a reference link was provided, it needs to be rendered on a separate * row within the table. */ if ((refLink != null) && (!isEmpty())) { ListTagUtil.write(pageContext, "<tr"); renderRowClassAndId(); ListTagUtil.write(pageContext, ">"); ListTagUtil.write( pageContext, "<td style=\"text-align: center;\" " + "class=\"first-column last-column\" "); ListTagUtil.write(pageContext, "colspan=" + String.valueOf(getColumnCount()) + ">"); ListTagUtil.write(pageContext, "<a href=\"" + refLink + "\" >"); /* Here we render the reflink and its key. If the key hasn't been set * we just display the link address itself. */ if (refLinkKey != null) { Object[] args = new Object[2]; args[0] = new Integer(getPageRowCount()); args[1] = refLinkKeyArg0; String message = LocalizationService.getInstance().getMessage(refLinkKey, args); ListTagUtil.write(pageContext, message); } else { ListTagUtil.write(pageContext, refLink); } ListTagUtil.write(pageContext, "</a>"); ListTagUtil.write(pageContext, "</td>"); ListTagUtil.write(pageContext, "</tr>"); } ListTagUtil.write(pageContext, "</table>"); renderPaginationControls(true); ListTagUtil.write(pageContext, "<!-- END " + getUniqueName() + " -->"); release(); return BodyTagSupport.EVAL_PAGE; }