下面列出了javax.servlet.jsp.JspWriter#write ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* {@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;
}
@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());
}
}
/**
* {@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);
}
}
/**
* {@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;
}
/**
* {@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);
}
}
/**
* 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(" ");
}
out.write(buildEndingTag());
}
catch (IOException ioe) {
throw new JspException("Difficulty rendering table cell", ioe);
}
}
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;
}
}
}
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;
}
/**
*
* @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);
}
}
/**
*
* @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);
}
}
/**
* {@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;
}
/**
* {@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;
}
/**
* @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);
}
}
/**
* 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);
}
}
/**
* 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 );
}
}
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$
}
/**
* 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 );
}
}
/**
* 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("\"> </td>");
out.write("<td class=\"total-line\" style=\"border-left: 0px;\">");
out.write("<strong>");
out.write(SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(totalLabelProperty));
out.write(" ");
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("\"> </td>");
}
out.write("</tr>");
}
catch (IOException ioe) {
throw new JspException("Difficulty rendering group total", ioe);
}
}
/**
* 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;
}
public static void out2(PageContext pageContext, boolean escapeXml,
Object obj) throws IOException {
JspWriter w = pageContext.getOut();
w.write(obj.toString());
}