Example usage for javax.servlet.jsp JspWriter print

List of usage examples for javax.servlet.jsp JspWriter print

Introduction

In this page you can find the example usage for javax.servlet.jsp JspWriter print.

Prototype


abstract public void print(Object obj) throws IOException;

Source Link

Document

Print an object.

Usage

From source file:no.kantega.publishing.admin.content.InputScreenRenderer.java

private int renderRepeaterAttribute(JspWriter out, ServletRequest request,
        Map<String, List<ValidationError>> fieldErrors, RepeaterAttribute repeaterAttribute, Integer tabIndex)
        throws IOException {

    try {// w  ww .  j a  v  a  2  s.  c  om
        out.print("\n<div class=\"contentAttributeRepeater");
        if (attributeIsHiddenEmpty(repeaterAttribute)) {
            this.hiddenAttributes = true;
            out.print(" attributeHiddenEmpty");
        }
        out.print("\" id=\"" + AttributeHelper.getInputContainerName(repeaterAttribute.getNameIncludingPath())
                + "\" data-title=\"" + repeaterAttribute.getTitle() + "\"\n>\n");
        request.setAttribute("repeater", repeaterAttribute);
        request.setAttribute("repeaterFieldName",
                AttributeHelper.getInputFieldName(repeaterAttribute.getNameIncludingPath()));

        pageContext.include("/admin/publish/attributes/repeater_start.jsp");

        int numberOfRows = repeaterAttribute.getNumberOfRows();

        for (int rowNo = 0; rowNo < numberOfRows; rowNo++) {
            out.print("<div class=\"contentAttributeRepeaterRow\">\n");
            request.setAttribute("repeaterRowNo", rowNo);
            pageContext.include("/admin/publish/attributes/repeater_row_start.jsp");
            List<Attribute> attributes = repeaterAttribute.getRow(rowNo);
            for (Attribute attribute : attributes) {
                tabIndex = renderAttribute(out, request, fieldErrors, attribute, tabIndex);
                tabIndex += 10;
            }
            pageContext.include("/admin/publish/attributes/repeater_row_end.jsp");
            out.print("</div>\n");
        }
        pageContext.include("/admin/publish/attributes/repeater_end.jsp");
        out.print("</div>");
    } catch (Exception e) {
        log.error("", e);
        String errorMessage = LocaleLabels.getLabel("aksess.editcontent.exception",
                Aksess.getDefaultAdminLocale());
        out.print("<div class=\"errorText\">" + errorMessage + ":" + repeaterAttribute.getTitle() + "</div>\n");
    }

    return tabIndex;
}

From source file:dk.netarkivet.archive.webinterface.BitpreserveFileState.java

/**
 * Print HTML formatted state for checksum errors on a given replica in a given locale.
 *
 * @param out The writer to write state to.
 * @param replica The replica to write state for.
 * @param locale The locale to write state in.
 * @throws IOException On IO trouble writing state to the writer.
 *///  w  w w  .j a  v  a 2s. c  om
public static void printChecksumErrorStateForReplica(JspWriter out, Replica replica, Locale locale)
        throws IOException {
    ArgumentNotValid.checkNotNull(out, "JspWriter out");
    ArgumentNotValid.checkNotNull(replica, "Replica replica");
    ArgumentNotValid.checkNotNull(locale, "Locale locale");
    ActiveBitPreservation bitPreservation = ActiveBitPreservationFactory.getInstance();

    // Header
    out.println(I18N.getString(locale, "checksum.status.for") + "&nbsp;<b>"
            + HTMLUtils.escapeHtmlValues(replica.getName()) + "</b>");
    out.println("<br/>");

    // Number of changed files
    long numberOfChangedFiles = bitPreservation.getNumberOfChangedFiles(replica);
    out.println(I18N.getString(locale, "number.of.files.with.error") + "&nbsp;"
            + HTMLUtils.localiseLong(numberOfChangedFiles, locale));

    // Link to fix-page
    if (numberOfChangedFiles > 0) {
        out.print("&nbsp;<a href=\"" + Constants.FILESTATUS_CHECKSUM_PAGE + "?"
                + (Constants.BITARCHIVE_NAME_PARAM + "=" + HTMLUtils.encodeAndEscapeHTML(replica.getName()))
                + " \">");
        out.print(I18N.getString(locale, "show.files.with.error"));
        out.print("</a>");
    }
    out.println("<br/>");

    // Time for last update
    Date lastChangedFilesupdate = bitPreservation.getDateForChangedFiles(replica);
    if (lastChangedFilesupdate == null) {
        lastChangedFilesupdate = new Date(0);
    }
    out.println(I18N.getString(locale, "last.update.at.0", lastChangedFilesupdate));
    out.println("<br/>");

    // Link for running a new job
    out.println("<a href=\"" + Constants.FILESTATUS_UPDATE_PAGE + "?" + Constants.UPDATE_TYPE_PARAM + "="
            + Constants.CHECKSUM_OPTION + "&amp;"
            + (Constants.BITARCHIVE_NAME_PARAM + "=" + HTMLUtils.encodeAndEscapeHTML(replica.getName())) + "\">"
            + I18N.getString(locale, "update.checksum.and.file.status.for.0", replica.getId()) + "</a>");

    // Separator
    out.println("<br/><br/>");
}

From source file:org.codelabor.system.web.taglib.LastIndexTag.java

@Override
public void doTag() throws JspException, IOException {
    logger.debug("doTag");

    parent = (PaginationTag) getParent();
    JspWriter out = getJspContext().getOut();

    // last page number of last
    logger.debug("lastPageNoOnLastIndex: {}", parent.getLastPageNoOnLastIndex());
    StringBuilder sb = new StringBuilder();
    sb.append(this.generateAnchorTagForLastIndex(parent.getQueryString(), parent.getLastPageNoOnLastIndex(),
            parent.getMaxRowPerPage()));
    sb.append(System.getProperty("line.separator"));
    out.print(sb.toString());
}

From source file:jp.terasoluna.fw.web.struts.taglib.BodyTag.java

/**
 * ^O]Jn?\bh?B/*  www . ja va 2  s.  c o  m*/
 *
 * @return ???w?B? <code>EVAL_BODY_INCLUDE</code>
 * @throws JspException JSPO
 */
@Override
public int doStartTag() throws JspException {

    HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();
    String onLoadBody = (String) req.getAttribute(ON_LOAD_KEY);

    StringBuilder tag = new StringBuilder();
    tag.append("<body");
    if (onLoadBody != null || onload != null) {
        tag.append(" onLoad=\"__onLoad__()\"");
    }
    if (this.onunload != null) {
        tag.append(" onUnLoad=\"" + this.onunload + "\"");
    }
    if (this.styleClass != null) {
        tag.append(" class=\"" + this.styleClass + "\"");
    }
    if (this.bgcolor != null) {
        tag.append(" bgcolor=\"" + this.bgcolor + "\"");
    }
    if (this.background != null) {
        if (this.background.startsWith("/")) {
            this.background = req.getContextPath() + this.background;
        } else {
            this.background = req.getContextPath() + "/" + this.background;
        }
        tag.append(" background=\"" + this.background + "\"");
    }
    if (this.text != null) {
        tag.append(" text=\"" + this.text + "\"");
    }
    if (this.link != null) {
        tag.append(" link=\"" + this.link + "\"");
    }
    if (this.vlink != null) {
        tag.append(" vlink=\"" + this.vlink + "\"");
    }
    if (this.alink != null) {
        tag.append(" alink=\"" + this.alink + "\"");
    }
    tag.append(">" + System.getProperty("line.separator"));

    StringBuilder func = null;
    if (onLoadBody != null || onload != null) {
        func = new StringBuilder();
        func.append("<script type=\"text/javascript\">" + System.getProperty("line.separator"));
        func.append("<!--" + System.getProperty("line.separator"));
        func.append("function __onLoad__() {" + System.getProperty("line.separator"));
        if (onload != null) {
            func.append("  ");
            func.append(onload);
            if (!onload.endsWith(";")) {
                func.append(";");
            }
            func.append(System.getProperty("line.separator"));
        }
        if (onLoadBody != null) {
            func.append(onLoadBody);
        }
        func.append("}" + System.getProperty("line.separator"));
        func.append("//-->" + System.getProperty("line.separator"));
        func.append("</script>" + System.getProperty("line.separator"));
    }

    try {
        JspWriter out = pageContext.getOut();
        out.print(tag.toString());
        if (func != null) {
            out.print(func.toString());
        }
    } catch (IOException e) {
        log.error("Output failed.");
        throw new JspTagException(e.toString());
    }

    return EVAL_BODY_INCLUDE;
}

From source file:org.codelabor.system.web.taglib.NextIndexTag.java

@Override
public void doTag() throws JspException, IOException {
    logger.debug("doTag");

    parent = (PaginationTag) getParent();
    JspWriter out = getJspContext().getOut();

    // first page number of previous
    logger.debug("firstPageNoOnNextIndex: {}", parent.getFirstPageNoOnNextIndex());
    StringBuilder sb = new StringBuilder();
    sb.append(this.generateAnchorTagForNextIndex(parent.getQueryString(), parent.getFirstPageNoOnNextIndex(),
            parent.getMaxRowPerPage()));
    sb.append(System.getProperty("line.separator"));
    out.print(sb.toString());
}

From source file:org.codelabor.system.web.taglib.FirstIndexTag.java

@Override
public void doTag() throws JspException, IOException {
    logger.debug("doTag");

    parent = (PaginationTag) getParent();
    JspWriter out = getJspContext().getOut();

    // first page number of first
    logger.debug("firstPageNoOnFirstIndex: {}", parent.getFirstPageNoOnFirstIndex());
    StringBuilder sb = new StringBuilder();
    sb.append(this.generateAnchorTagForFirstIndex(parent.getQueryString(), parent.getFirstPageNoOnFirstIndex(),
            parent.getMaxRowPerPage()));
    sb.append(System.getProperty("line.separator"));
    out.print(sb.toString());
}

From source file:info.magnolia.cms.taglibs.util.TextToImageTag.java

/**
 * Draws a div box that contains the text images.
 * @param imageURLs an array of urls//from w ww  .  ja v a 2s .  co  m
 * @param subStrings an array of strings
 * @throws IOException jspwriter exception
 */
private void drawTextImages(String[] imageURIs, String[] subStrings) throws IOException {
    JspWriter out = this.getJspContext().getOut();

    if (this.divCSS != null) {
        out.print("<div class=\"");
        out.print(this.divCSS);
        out.print("\">");
    }

    for (int i = 0; i < imageURIs.length; i++) {
        out.print("<img class=\"");
        if (this.textSplit.equals(TEXT_SPLIT_CHARACTERS)) {
            out.print(CSS_CHARACTER_IMAGE);
        } else if (this.textSplit.equals(TEXT_SPLIT_WORDS)) {
            out.print(CSS_WORD_IMAGE);
        } else {
            out.print(CSS_TEXT_IMAGE);
        }
        out.print("\" src=\"");
        out.print(imageURIs[i]);
        out.print("\" alt=\"");
        out.print(subStrings[i]);
        out.print("\" />");
    }

    if (this.divCSS != null) {
        out.print("</div>");
    }
}

From source file:org.codelabor.system.web.taglib.PreviousIndexTag.java

@Override
public void doTag() throws JspException, IOException {
    logger.debug("doTag");

    parent = (PaginationTag) getParent();
    JspWriter out = getJspContext().getOut();

    // first page number of previous
    logger.debug("firstPageNoOnPreviousIndex: {}", parent.getFirstPageNoOnPreviousIndex());
    StringBuilder sb = new StringBuilder();
    sb.append(this.generateAnchorTagForPreviousIndex(parent.getQueryString(),
            parent.getFirstPageNoOnPreviousIndex(), parent.getMaxRowPerPage()));
    sb.append(System.getProperty("line.separator"));
    out.print(sb.toString());
}

From source file:com.googlecode.psiprobe.jsp.OutTag.java

private void print(String displayValue, JspWriter out) throws JspException {
    try {/*ww w.  j av a  2  s  . c o  m*/
        if (maxLength != -1 && displayValue.length() > maxLength) {
            String newValue;
            if (ellipsisRight) {
                newValue = displayValue.substring(0, maxLength - 3) + "...";
            } else {
                newValue = "..." + displayValue.substring(displayValue.length() - maxLength + 3);
            }
            String title = StringEscapeUtils.escapeHtml(displayValue);
            out.print("<span title=\"" + title + "\">" + newValue + "</span>");
        } else {
            out.print(displayValue);
        }
    } catch (IOException e) {
        throw new JspException(e);
    }
}

From source file:org.apache.hadoop.hdfs.server.namenode.JspHelper.java

public void addTableFooter(JspWriter out) throws IOException {
    out.print("</tbody></table>");
}