Java Code Examples for javax.servlet.jsp.tagext.BodyTagSupport#findAncestorWithClass()
The following examples show how to use
javax.servlet.jsp.tagext.BodyTagSupport#findAncestorWithClass() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SelectableColumnTag.java From spacewalk with GNU General Public License v2.0 | 6 votes |
/** * 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()); }
Example 2
Source File: SelectableColumnTag.java From spacewalk with GNU General Public License v2.0 | 6 votes |
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"); }
Example 3
Source File: ColumnTag.java From uyuni with GNU General Public License v2.0 | 5 votes |
/** * ${@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; }
Example 4
Source File: ColumnTag.java From uyuni with GNU General Public License v2.0 | 5 votes |
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(); }
Example 5
Source File: ColumnTag.java From uyuni with GNU General Public License v2.0 | 5 votes |
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)); }
Example 6
Source File: DecoratorTag.java From uyuni with GNU General Public License v2.0 | 5 votes |
/** * {@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(); }
Example 7
Source File: SelectableColumnTag.java From spacewalk with GNU General Public License v2.0 | 5 votes |
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); }
Example 8
Source File: ColumnTag.java From spacewalk with GNU General Public License v2.0 | 5 votes |
/** * ${@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; }
Example 9
Source File: RowRendererTag.java From spacewalk with GNU General Public License v2.0 | 5 votes |
/** * {@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(); }
Example 10
Source File: RowRendererTag.java From uyuni with GNU General Public License v2.0 | 5 votes |
/** * {@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(); }
Example 11
Source File: ListTagUtil.java From spacewalk with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example 12
Source File: ColumnTag.java From spacewalk with GNU General Public License v2.0 | 5 votes |
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); }
Example 13
Source File: SelectableColumnTag.java From uyuni with GNU General Public License v2.0 | 4 votes |
private void render(String value) throws JspException { writeStartingTd(); String id = ListTagHelper.getObjectId(getCurrent()); String checkboxId = makeCheckboxId(listName, id); renderHiddenItem(id, value); if (isHideDisabled() && isDisabled()) { return; } ListTagUtil.write(pageContext, "<input type=\"checkbox\" "); boolean selected = isSelected(); if (selected) { ListTagUtil.incrementPersistentCounter(pageContext, listName + "_selected"); ListTagUtil.write(pageContext, "checked "); } if (isDisabled()) { ListTagUtil.write(pageContext, "disabled "); } ListTagUtil.write(pageContext, "id=\""); ListTagUtil.write(pageContext, checkboxId); String itemsName = ListTagUtil.makeSelectedItemsName(listName); ListTag parent = (ListTag) BodyTagSupport.findAncestorWithClass(this, ListTag.class); if (!parent.isParentAnElement() && RhnListTagFunctions.isExpandable(getCurrent())) { itemsName = "parent_" + itemsName; } ListTagUtil.write(pageContext, "\" name=\"" + itemsName + "\" "); ListTagUtil.write(pageContext, "value=\""); ListTagUtil.write(pageContext, value); ListTagUtil.write(pageContext, "\" "); renderOnClick(); ListTagUtil.write(pageContext, "/>"); if (selected && !StringUtils.isBlank(rhnSet)) { String scriptId = "document.getElementById('" + checkboxId + "')"; addPostScript(getOnClickScript(CLICKED_CLIENT_SIDE, scriptId), listName, pageContext.getRequest()); } }
Example 14
Source File: ListTag.java From uyuni with GNU General Public License v2.0 | 4 votes |
private void verifyEnvironment() throws JspException { if (BodyTagSupport.findAncestorWithClass(this, ListSetTag.class) == null) { throw new JspException("List must be enclosed by a ListSetTag"); } }
Example 15
Source File: CSVTag.java From uyuni with GNU General Public License v2.0 | 4 votes |
private void verifyEnvironment() throws JspException { if (BodyTagSupport.findAncestorWithClass(this, ListSetTag.class) == null) { throw new JspException("List must be enclosed by a ListSetTag"); } }
Example 16
Source File: CSVTag.java From spacewalk with GNU General Public License v2.0 | 4 votes |
private void verifyEnvironment() throws JspException { if (BodyTagSupport.findAncestorWithClass(this, ListSetTag.class) == null) { throw new JspException("List must be enclosed by a ListSetTag"); } }
Example 17
Source File: ExpandableColumnTag.java From spacewalk with GNU General Public License v2.0 | 4 votes |
protected Object getCurrent() { ListTag parent = (ListTag) BodyTagSupport.findAncestorWithClass(this, ListTag.class); return parent.getCurrentObject(); }
Example 18
Source File: ListTag.java From spacewalk with GNU General Public License v2.0 | 4 votes |
private void verifyEnvironment() throws JspException { if (BodyTagSupport.findAncestorWithClass(this, ListSetTag.class) == null) { throw new JspException("List must be enclosed by a ListSetTag"); } }
Example 19
Source File: ColumnTag.java From uyuni with GNU General Public License v2.0 | 4 votes |
protected String getListName() { ListTag parent = (ListTag) BodyTagSupport.findAncestorWithClass(this, ListTag.class); return parent.getUniqueName(); }
Example 20
Source File: ExpandableColumnTag.java From uyuni with GNU General Public License v2.0 | 4 votes |
protected String getListName() { ListTag parent = (ListTag) BodyTagSupport.findAncestorWithClass(this, ListTag.class); return parent.getUniqueName(); }