List of usage examples for javax.servlet.jsp JspWriter print
abstract public void print(Object obj) throws IOException;
From source file:org.rhq.enterprise.gui.legacy.taglib.ConstantsTag.java
protected void doOutput(Map fieldMap, JspWriter out) throws java.io.IOException { out.print(fieldMap.get(symbol)); }
From source file:com.draagon.meta.web.view.html.HotLinkView.java
/** * Renders a hotlink view/* w w w .j a v a 2 s .c o m*/ */ protected void doHotLinkView(PageContext page, Object o, String label, int mode, Map params) throws IOException, MetaException { String link = createLink(page, o, mode, params); String val = getMetaField(o).getString(o); if (link == null && val == null) { return; } if (!hasAttribute("viewRef")) { HtmlViewHelper.drawLink(page, link, val, getLinkClass(params), params); } else { String viewRef = (String) getAttribute("viewRef"); WebView mv = (WebView) getMetaField(o).getView(viewRef); String linkClass = getLinkClass(params); JspWriter out = page.getOut(); // if ( text == null ) text = " "; if (link != null) { out.print("<a"); if (linkClass != null) { out.print(" class=\"" + linkClass + "\""); } out.print(" href=\"" + link + "\">"); } mv.doView(page, o, mode, params); // out.print( text ); if (link != null) { out.print("</a>"); } } }
From source file:org.kuali.mobility.tags.LocalisedFieldTag.java
/** * Writes the hidden input to give a name for the input localised code. * * @param out/*from ww w. j av a 2s .c o m*/ * @throws IOException */ private void writeHiddenInputCode(JspWriter out) throws IOException { out.print("<input type=\"hidden\" "); out.print("name=\"" + name + ".code\" "); if (code != null) { out.print("value=\"" + code + "\" "); } else { out.print("value=\"\" "); } out.println(" />"); }
From source file:info.magnolia.cms.taglibs.util.Breadcrumb.java
/** * @see javax.servlet.jsp.tagext.Tag#doStartTag() *///from w w w . j a v a 2 s . c o m public int doStartTag() throws JspException { HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); Content actpage = Resource.getCurrentActivePage(request); int endLevel = 0; try { endLevel = actpage.getLevel(); if (this.excludeCurrent) { endLevel--; } JspWriter out = pageContext.getOut(); for (int i = this.startLevel; i <= endLevel; i++) { if (i != this.startLevel) { out.print(StringUtils.defaultString(this.delimiter, " > ")); //$NON-NLS-1$ } if (this.link) { out.print("<a href=\""); //$NON-NLS-1$ out.print(request.getContextPath()); out.print(actpage.getAncestor(i).getHandle() + "." + Server.getDefaultExtension()); out.print("\">"); //$NON-NLS-1$ } out.print(actpage.getAncestor(i).getTitle()); if (this.link) { out.print("</a>"); //$NON-NLS-1$ } } } catch (RepositoryException e) { log.debug("Exception caught: " + e.getMessage(), e); //$NON-NLS-1$ } catch (IOException e) { throw new NestableRuntimeException(e); } return super.doStartTag(); }
From source file:org.opencms.workplace.list.CmsListExplorerFrameset.java
/** * Validates the needed parameters and display the frameset.<p> * /*from w w w . j a va2s . c o m*/ * @throws IOException in case of errros displaying to the required page */ public void displayFrameSet() throws IOException { if (getJsp().getRequest().getParameter(CmsListExplorerFrameset.PARAM_PAGE) != null) { int page = Integer.parseInt(getJsp().getRequest().getParameter(CmsListExplorerFrameset.PARAM_PAGE)); getSettings().setExplorerPage(page); if (getSettings().getCollector() instanceof I_CmsListResourceCollector) { I_CmsListResourceCollector collector = (I_CmsListResourceCollector) getSettings().getCollector(); collector.setPage(page); } } JspWriter out = getJsp().getJspContext().getOut(); out.print(defaultActionHtml()); }
From source file:org.hyperic.hq.ui.taglib.ConstantsTag.java
protected void doOutput(HashMap fieldMap, JspWriter out) throws java.io.IOException { out.print(fieldMap.get(symbol)); }
From source file:net.jcreate.e3.tree.taglib.TreeTag.java
public int doEndTag() throws JspException { TreeModel treeModel = NodeUtils.convert(this.nodes, this.idParentIds); WebTreeBuilder treeBuilder = BuilderFactory.getInstance(this.builder); WebContext context = new JspPageWebContext(this.pageContext); System.out.println("context path=" + context.getContextPath()); treeBuilder.init(context);/*from www .j a v a 2s. com*/ java.util.Iterator keys = dynamicAttributes.keySet().iterator(); while (keys.hasNext()) { Object key = keys.next(); Object value = dynamicAttributes.get(key); this.setProperty(treeBuilder, (String) key, value); } /** * @todo: ???TreeDirector */ TreeDirector director = new DefaultTreeDirector(); director.setComparator(getRealComparator()); if (visitor != null) { director.setNodeVisitor(visitor); } director.build(treeModel, treeBuilder); String treeScript = treeBuilder.getTreeScript(); JspWriter writer = this.pageContext.getOut(); cleanUp(); try { writer.print(treeScript); } catch (IOException e) { e.printStackTrace(); throw new JspException(e.getMessage(), e); } return super.doEndTag(); }
From source file:org.apache.webapp.admin.AttributeTag.java
/** * Render the JMX MBean attribute identified by this tag * * @exception JspException if a processing exception occurs *///from w ww . j av a2 s . co m public int doEndTag() throws JspException { // Retrieve the object name identified by our attributes Object bean = null; if (scope == null) { bean = pageContext.findAttribute(name); } else if ("page".equalsIgnoreCase(scope)) { bean = pageContext.getAttribute(name, PageContext.PAGE_SCOPE); } else if ("request".equalsIgnoreCase(scope)) { bean = pageContext.getAttribute(name, PageContext.REQUEST_SCOPE); } else if ("session".equalsIgnoreCase(scope)) { bean = pageContext.getAttribute(name, PageContext.SESSION_SCOPE); } else if ("application".equalsIgnoreCase(scope)) { bean = pageContext.getAttribute(name, PageContext.APPLICATION_SCOPE); } else { throw new JspException("Invalid scope value '" + scope + "'"); } if (bean == null) { throw new JspException("No bean '" + name + "' found"); } if (property != null) { try { bean = PropertyUtils.getProperty(bean, property); } catch (Throwable t) { throw new JspException("Exception retrieving property '" + property + "': " + t); } if (bean == null) { throw new JspException("No property '" + property + "' found"); } } // Convert to an object name as necessary ObjectName oname = null; try { if (bean instanceof ObjectName) { oname = (ObjectName) bean; } else if (bean instanceof String) { oname = new ObjectName((String) bean); } else { oname = new ObjectName(bean.toString()); } } catch (Throwable t) { throw new JspException("Exception creating object name for '" + bean + "': " + t); } // Acquire a reference to our MBeanServer MBeanServer mserver = (MBeanServer) pageContext.getAttribute("org.apache.catalina.MBeanServer", PageContext.APPLICATION_SCOPE); if (mserver == null) throw new JspException("MBeanServer is not available"); // Retrieve the specified attribute from the specified MBean Object value = null; try { value = mserver.getAttribute(oname, attribute); } catch (Throwable t) { throw new JspException("Exception retrieving attribute '" + attribute + "'"); } // Render this value to our current output writer if (value != null) { JspWriter out = pageContext.getOut(); try { out.print(value); } catch (IOException e) { throw new JspException("IOException: " + e); } } // Evaluate the remainder of this page return (EVAL_PAGE); }
From source file:net.testdriven.psiprobe.jsp.VisualScoreTag.java
@Override public int doAfterBody() throws JspException { if (value < minValue) { log.info("value " + value + " is less than min value " + minValue); value = minValue;/*from ww w . j av a 2 s. c om*/ } if (value > maxValue) { log.info("value " + value + " is greater than max value " + maxValue); value = maxValue; } if (value + value2 < minValue || value2 < 0) { log.info("value2 " + value2 + " is less than min value"); value2 = 0; } if (value + value2 > maxValue) { log.info("value2 " + value2 + " is greater than max value"); value2 = maxValue - value; } double unitSize = (maxValue - minValue) / (fullBlocks * partialBlocks); double blockWidth = unitSize * partialBlocks; int fullRedBlockCount = (int) Math.floor(value / blockWidth); int partialRedBlockIndex = (int) Math.floor((value - fullRedBlockCount * blockWidth) / unitSize); int partialBlueBlockIndex1 = (partialRedBlockIndex > 0 ? Math.min((int) Math.floor(value2 / unitSize), partialBlocks - partialRedBlockIndex) : 0); int fullBlueBlockCount = Math.max(0, (int) Math.floor(value2 / blockWidth) - (partialRedBlockIndex > 0 ? 1 : 0)); int partialBlueBlockIndex2 = (int) Math.floor( (value2 - (fullBlueBlockCount * blockWidth) - (partialBlueBlockIndex1 * unitSize)) / unitSize); BodyContent bc = getBodyContent(); String body = bc.getString().trim(); StringBuilder buf = new StringBuilder(); // Beginning if (showA) { String format = "a0"; if (fullRedBlockCount > 0 || partialRedBlockIndex > 0) { format = "a1"; } else if (partialBlueBlockIndex1 == 0 && (fullBlueBlockCount > 0 || partialBlueBlockIndex2 > 0)) { format = "a2"; } buf.append(MessageFormat.format(body, new Object[] { format })); } // Full red blocks String fullRedBody = MessageFormat.format(body, partialBlocks + "+0"); for (int i = 0; i < fullRedBlockCount; i++) { buf.append(fullRedBody); } // Mixed red/blue block (mid-block transition) if (partialRedBlockIndex > 0) { String partialBody = MessageFormat.format(body, partialRedBlockIndex + "+" + partialBlueBlockIndex1); buf.append(partialBody); } // Full blue blocks String fullBlueBody = MessageFormat.format(body, "0+" + partialBlocks); for (int i = 0; i < fullBlueBlockCount; i++) { buf.append(fullBlueBody); } // Partial blue block if (partialBlueBlockIndex2 > 0) { String partialBody = MessageFormat.format(body, "0+" + partialBlueBlockIndex2); buf.append(partialBody); } // Empty blocks int emptyBlocks = showEmptyBlocks ? fullBlocks - (fullRedBlockCount + fullBlueBlockCount + (partialRedBlockIndex > 0 ? 1 : 0) + (partialBlueBlockIndex2 > 0 ? 1 : 0)) : 0; if (emptyBlocks > 0) { String emptyBody = MessageFormat.format(body, "0+0"); for (int i = 0; i < emptyBlocks; i++) { buf.append(emptyBody); } } // End if (showB) { String format = "b0"; if (fullRedBlockCount == fullBlocks) { format = "b1"; } else if (fullRedBlockCount + (partialRedBlockIndex + partialBlueBlockIndex1 == partialBlocks ? 1 : 0) + fullBlueBlockCount == fullBlocks) { format = "b2"; } buf.append(MessageFormat.format(body, new Object[] { format })); } try { JspWriter out = bc.getEnclosingWriter(); out.print(buf.toString()); } catch (IOException ioe) { throw new JspException("Error:IOException while writing to client" + ioe.getMessage()); } return SKIP_BODY; }
From source file:org.kuali.mobility.tags.LocalisedFieldTag.java
/** * Writes the required HTML for a language's input * * @param out/*from w ww .j a v a2s .c o m*/ * @param language * @throws IOException */ private void writeInputForLanguage(JspWriter out, String language) throws IOException { out.print("<div data-l10n-lang=\""); out.print(language); // If it is not the default language, hide it for now if (!getDefaultLanguage().equals(language)) { out.print("\" style=\"display: none\" "); } out.println("\">"); this.writeInput(out, language); out.println("</div>"); }