javax.servlet.jsp.JspWriter#write ( )源码实例Demo

下面列出了javax.servlet.jsp.JspWriter#write ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: uyuni   文件: RequiredFieldTag.java
/**
 * {@inheritDoc}
 */
public int doEndTag() throws JspException {
    JspWriter writer = pageContext.getOut();
    //<span class="required-form-field">*</span>
    HtmlTag span = new HtmlTag("span");
    span.setAttribute("class", REQUIRED_FIELD_CSS);
    span.addBody("*");
    try {
        writer.write(span.render());
        if (!StringUtils.isBlank(key)) {
            LocalizationService ls = LocalizationService.getInstance();
            String msg = ls.getMessage(key);
            if (msg.endsWith(":")) {
                writer.write(":");
            }
        }

    }
    catch (IOException e) {
        throw new JspException(e);
    }
    return SKIP_BODY;
}
 
源代码2 项目: jstorm   文件: SubMetricTag.java
@Override
public void doTag() throws JspException {
    JspWriter out = getJspContext().getOut();
    try {
        StringBuilder sb = new StringBuilder();
        if (metric.size() > 0) {
            if (isHidden) {
                sb.append(String.format("<div class='%s hidden'>", clazz));
            } else {
                sb.append(String.format("<div class='%s'>", clazz));
            }
            for (String parent : parentComp) {
                String key = metricName + "@" + parent;
                String v = metric.get(key);
                if (v != null) {
                    sb.append(v);
                }
                sb.append("<br/>");
            }
            sb.append("</div>");
            out.write(sb.toString());
        }
    } catch (IOException e) {
        throw new JspException("Error: " + e.getMessage());
    }
}
 
源代码3 项目: spacewalk   文件: ToolTipTag.java
/**
 * {@inheritDoc}
 */
@Override
public int doStartTag() throws JspException {
    LocalizationService ls = LocalizationService.getInstance();
    HtmlTag strong = new HtmlTag("strong");
    strong.addBody(ls.getMessage(geTypeKey()) + ": ");

    JspWriter writer = pageContext.getOut();
    try {
        writer.write("<p class=\"small-text\">");
        writer.write(strong.render());
        if (!StringUtils.isBlank(key)) {
            writer.write(ls.getMessage(key));
        }
        return EVAL_BODY_INCLUDE;
    }
    catch (IOException e) {
        throw new JspException(e);
    }

}
 
源代码4 项目: 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;
}
 
源代码5 项目: spacewalk   文件: RequiredFieldTag.java
/**
 * {@inheritDoc}
 */
@Override
public int doStartTag() throws JspException {
    // <bean:message key="cobbler.snippet.name"/>
    // <span class="required-form-field">*</span>
    LocalizationService ls = LocalizationService.getInstance();
    JspWriter writer = pageContext.getOut();
    try {
        if (!StringUtils.isBlank(key)) {
            String msg = ls.getMessage(key);
            if (msg.endsWith(":")) {
                msg = msg.substring(0, msg.length() - 1);
            }
            writer.write(msg);
        }
        return EVAL_BODY_INCLUDE;
    }
    catch (IOException e) {
        throw new JspException(e);
    }

}
 
源代码6 项目: kfs   文件: TableCellRenderer.java
/**
 * Renders the table cell as a header cell as well as rendering all children renderable elements of the cell
 * @see org.kuali.kfs.sys.document.web.renderers.Renderer#render(javax.servlet.jsp.PageContext, javax.servlet.jsp.tagext.Tag)
 */
public void render(PageContext pageContext, Tag parentTag) throws JspException {
    JspWriter out = pageContext.getOut();
    try {
        out.write(buildBeginningTag());
        if (cell.hasChildElements()) {
            cell.renderChildrenElements(pageContext, parentTag);
        } else {
            out.write("&nbsp;");
        }
        out.write(buildEndingTag());
    }
    catch (IOException ioe) {
        throw new JspException("Difficulty rendering table cell", ioe);
    }
}
 
源代码7 项目: Tomcat8-Source-Read   文件: Out.java
public static boolean output(JspWriter out, Object input, String value,
        String defaultValue, boolean escapeXml) throws IOException {
    if (input instanceof Reader) {
        char[] buffer = new char[8096];
        int read = 0;
        while (read != -1) {
            read = ((Reader) input).read(buffer);
            if (read != -1) {
                if (escapeXml) {
                    String escaped = Util.escapeXml(buffer, read);
                    if (escaped == null) {
                        out.write(buffer, 0, read);
                    } else {
                        out.print(escaped);
                    }
                } else {
                    out.write(buffer, 0, read);
                }
            }
        }
        return true;
    } else {
        String v = value != null ? value : defaultValue;
        if (v != null) {
            if(escapeXml){
                v = Util.escapeXml(v);
            }
            out.write(v);
            return true;
        } else {
            return false;
        }
    }
}
 
源代码8 项目: attic-stratos   文件: Report.java
public int doStartTag() throws JspException {
    //check permission.
    HttpServletRequest req = (HttpServletRequest)
            pageContext.getRequest();
    if(!CarbonUIUtil.isUserAuthorized(req, "/permission/admin/manage/report")){
      return EVAL_PAGE;
    }
    JspWriter writer = pageContext.getOut();

    String context = "<div style='float:right;padding-bottom:5px;padding-right:15px;'>";

    if(pdfReport){
       context  = context+ "<a target='_blank' class='icon-link' style='background-image:url(../admin/images/pdficon.gif);' href=\"../report" + "?" +"reportDataSession="+ reportDataSession + "&component=" + component + "&template=" + template + "&type=pdf" +  "\">Generate Pdf Report</a>";
    }
    if(htmlReport){
        context  = context+ "<a target='_blank' class='icon-link' style='background-image:url(../admin/images/htmlicon.gif);' href=\"../report" + "?" + "reportDataSession="+ reportDataSession + "&component=" + component + "&template=" + template + "&type=html" + "\">Generate Html Report</a>";

    }
    if(excelReport){
        context  = context+ "<a target='_blank' class='icon-link' style='background-image:url(../admin/images/excelicon.gif);' href=\"../report" + "?" + "reportDataSession="+ reportDataSession + "&component=" + component + "&template=" + template + "&type=excel" +"\">Generate Excel Report</a>";

    }
    context  = context + "</div><div style='clear:both;'></div>";

    try {
        writer.write(context);
    } catch (IOException e) {
        String msg = "Cannot write reporting tag content";

        throw new JspException(msg, e);
    }
    return EVAL_PAGE;


}
 
源代码9 项目: kfs   文件: DateRenderer.java
/**
 * 
 * @see org.kuali.kfs.sys.document.web.renderers.TextRenderer#render(javax.servlet.jsp.PageContext, javax.servlet.jsp.tagext.Tag, org.kuali.rice.krad.bo.BusinessObject)
 */
@Override
public void render(PageContext pageContext, Tag parentTag) throws JspException {
    super.render(pageContext, parentTag);
    
    JspWriter out = pageContext.getOut();
    try {
        out.write(buildDateImage());
        out.write(buildDateJavascript());
    }
    catch (IOException ioe) {
        throw new JspException("Difficulty rendering date picker", ioe);
    }
}
 
源代码10 项目: kfs   文件: TableRenderer.java
/**
 * 
 * @see org.kuali.kfs.sys.document.web.renderers.Renderer#render(javax.servlet.jsp.PageContext, javax.servlet.jsp.tagext.Tag)
 */
public void render(PageContext pageContext, Tag parentTag) throws JspException {
    JspWriter out = pageContext.getOut();
    try {
        out.write(buildBeginningTableTag());
        table.renderChildrenRows(pageContext, parentTag);
        out.write(buildEndingTableTag());
    }
    catch (IOException ioe) {
        throw new JspException("Difficulty with rendering inner table", ioe);
    }
}
 
源代码11 项目: uyuni   文件: SubmittedTag.java
/**
 * {@inheritDoc}
 */
public int doEndTag() throws JspException {
    HtmlTag input = new HtmlTag("input");
    input.setAttribute("type", HIDDEN);
    input.setAttribute("name", RhnAction.SUBMITTED);
    input.setAttribute("value", TRUE);
    JspWriter writer = pageContext.getOut();
    try {
        writer.write(input.render());
    }
    catch (IOException e) {
        throw new JspException(e);
    }
    return SKIP_BODY;
}
 
源代码12 项目: spacewalk   文件: SubmittedTag.java
/**
 * {@inheritDoc}
 */
public int doEndTag() throws JspException {
    HtmlTag input = new HtmlTag("input");
    input.setAttribute("type", HIDDEN);
    input.setAttribute("name", RhnAction.SUBMITTED);
    input.setAttribute("value", TRUE);
    JspWriter writer = pageContext.getOut();
    try {
        writer.write(input.render());
    }
    catch (IOException e) {
        throw new JspException(e);
    }
    return SKIP_BODY;
}
 
源代码13 项目: kfs   文件: DynamicReadOnlyRender.java
/**
 * @see org.kuali.kfs.sys.document.web.renderers.Renderer#render(javax.servlet.jsp.PageContext, javax.servlet.jsp.tagext.Tag)
 */
public void render(PageContext pageContext, Tag parentTag) throws JspException {
    JspWriter out = pageContext.getOut();

    try {
        String value = discoverRenderValue();            
        out.write(buildBeginSpan());
        
        if (!StringUtils.isEmpty(value)) {
            if (shouldRenderInquiryLink()) {
                out.write(buildBeginInquiryLink());
            }                
            out.write(value);                
            if (shouldRenderInquiryLink()) {
                out.write(buildEndInquiryLink());
            }                                
        } else {
            out.write(buildNonBreakingSpace());
        }
        
        out.write(buildEndSpan());
        renderShadowInputTag(pageContext, parentTag);
    }
    catch (IOException ioe) {
        throw new JspException("Difficulty rendering read only field", ioe);
    }
}
 
源代码14 项目: kfs   文件: QuickFinderRenderer.java
/**
 * Renders the quick finder to the page context
 * @see org.kuali.kfs.sys.document.web.renderers.Renderer#render(javax.servlet.jsp.PageContext, javax.servlet.jsp.tagext.Tag, org.kuali.rice.krad.bo.BusinessObject)
 */
public void render(PageContext pageContext, Tag parentTag) throws JspException {
    JspWriter out = pageContext.getOut();
    try {
        out.write(buildQuickFinderHtml(pageContext));
    } catch (IOException ioe) {
        throw new JspException("Cannot render quick finder for field "+getField(), ioe);
    }
}
 
源代码15 项目: birt   文件: ParamDefTag.java
/**
 * Handle Exception
 * 
 * @param e
 * @throws JspException
 */
protected void __handleException( Exception e ) throws JspException
{
	JspWriter writer = pageContext.getOut( );
	try
	{
		writer.write( "<font color='red'>" ); //$NON-NLS-1$
		writer.write( e.getMessage( ) );
		writer.write( "</font>" ); //$NON-NLS-1$
	}
	catch ( IOException err )
	{
		throw new JspException( err );
	}
}
 
源代码16 项目: birt   文件: BirtTagUtil.java
public static void writeExtScript(JspWriter writer, String fileName ) throws IOException
{
	writer
	.write( "<script src=\"" //$NON-NLS-1$
			+ fileName
			+ "\" type=\"text/javascript\"></script>\n" ); //$NON-NLS-1$		
}
 
源代码17 项目: birt   文件: AbstractBaseTag.java
/**
 * Handle Exception
 * 
 * @param e
 * @throws JspException
 */
protected void __handleException( Exception e ) throws JspException
{
	JspWriter writer = pageContext.getOut( );
	try
	{
		writer.write( "<font color='red'>" ); //$NON-NLS-1$
		writer.write( e.getMessage( ) );
		writer.write( "</font>" ); //$NON-NLS-1$
	}
	catch ( IOException err )
	{
		throw new JspException( err );
	}
}
 
源代码18 项目: kfs   文件: GroupTotalRenderer.java
/**
 * Uses a Struts write tag to dump out the total
 * @see org.kuali.kfs.sys.document.web.renderers.Renderer#render(javax.servlet.jsp.PageContext, javax.servlet.jsp.tagext.Tag)
 */
public void render(PageContext pageContext, Tag parentTag) throws JspException {
    JspWriter out = pageContext.getOut();
    
    try {
        out.write("<tr>");
        
        final int emptyCellSpanBefore = this.getColumnNumberOfRepresentedCell() - 1;
        out.write("<td  class=\"total-line\" colspan=\"");
        out.write(Integer.toString(emptyCellSpanBefore));
        out.write("\">&nbsp;</td>");
        
        out.write("<td class=\"total-line\" style=\"border-left: 0px;\">");
        
        out.write("<strong>");
        
        out.write(SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(totalLabelProperty));
        out.write("&nbsp;");
        
        writeTag.setPageContext(pageContext);
        writeTag.setParent(parentTag);
        writeTag.setProperty(getTotalProperty());
        writeTag.doStartTag();
        writeTag.doEndTag();
        
        out.write("</strong>");
        
        out.write("</td>");
        
        final int emptyCellSpanAfter = this.getCellCount() - this.getColumnNumberOfRepresentedCell();
        if(emptyCellSpanAfter > 0) {
            out.write("<td class=\"total-line\" style=\"border-left: 0px;\" colspan=\"");
            out.write(Integer.toString(emptyCellSpanAfter));
            out.write("\">&nbsp;</td>");
        }
        
        out.write("</tr>");
    }
    catch (IOException ioe) {
        throw new JspException("Difficulty rendering group total", ioe);
    }
}
 
源代码19 项目: ontopia   文件: PluginListTag.java
/**
 * Process the start tag for this instance.
 */
@Override
public int doStartTag() throws JspTagException {
  ContextTag contextTag = FrameworkUtils.getContextTag(pageContext);
  if (contextTag == null)
    throw new JspTagException("The framework:pluginList tag can only be used " +
                              "inside the context tag");

  try {
    JspWriter out = pageContext.getOut();

    Iterator it = contextTag.getNavigatorConfiguration()
      .getPlugins(groupId).iterator();
    PluginIF plugin;
    String html;
    boolean isFirst = true;
    // loop over all activated plugins and let them generate html 
    while (it.hasNext()) {
      plugin = (PluginIF) it.next();
      // if this plugin should be excluded than go to next one
      if (excludePluginId != null && excludePluginId.equals(plugin.getId()))
        continue;
      // if activated then generate HTML
      if (plugin.getState() == PluginIF.ACTIVATED) {          
        html = plugin.generateHTML(contextTag);
        if (html != null) {
          // don't put out separator first time and last time
          if (!isFirst || preSeparatorFlag)
            out.write(separator);
          
          if (plugin instanceof IncludePluginIF)              
            pageContext.include(html);
          else
            out.write(html);
          
          isFirst = false;
        }
      }
    } // while it

  } catch (ServletException sr) {
    throw JSPEngineWrapper.getJspTagException("Error in PluginListTag", sr);
  } catch (IOException ioe) {
    throw JSPEngineWrapper.getJspTagException("Error in PluginListTag", ioe);
  }

  // empty tag has not to eval anything
  return SKIP_BODY;
}
 
源代码20 项目: oslits   文件: EgovComCrossSiteHndlr.java
public static void out2(PageContext pageContext, boolean escapeXml,
		Object obj) throws IOException {
	JspWriter w = pageContext.getOut();

	w.write(obj.toString());

}