Example usage for javax.servlet.jsp JspWriter println

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

Introduction

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

Prototype


abstract public void println(Object x) throws IOException;

Source Link

Document

Print an Object and then terminate the line.

Usage

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.ja  v  a 2  s  . com*/
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:dk.netarkivet.archive.webinterface.BitpreserveFileState.java

/**
 * Print a checkbox that on click will turn a number of checkboxes of a certain type on or off.
 *
 * @param out The stream to print the checkbox to.
 * @param command The type of checkbox./*from w  ww  .j a  va 2 s  .c  o  m*/
 * @param numberOfCheckboxes The total number of checksboxes possible to turn on or off.
 * @param label The I18N label for the describing text. An input box with the number to change will be added as
 * parameter {0} in this label.
 * @param locale The locale for the checkbox.
 * @throws IOException On trouble printing the checkbox.
 */
private static void printMultipleToggler(JspWriter out, String command, int numberOfCheckboxes, String label,
        Locale locale) throws IOException {
    out.print("<input type=\"checkbox\" id=\"toggle" + command + "\" onclick=\"toggleCheckboxes('" + command
            + "')\"/>");
    out.print(I18N.getString(locale, label, "<input id=\"toggleAmount" + command + "\" value=\""
            + Math.min(numberOfCheckboxes, Constants.MAX_TOGGLE_AMOUNT) + "\" />"));
    out.println("<br/> ");
}

From source file:fll.web.scoreEntry.ScoreEntry.java

/**
 * Generates the portion of the score entry form where the user checks whether
 * the score has been double-checked or not.
 *///from w  w w  .j  av a 2 s  .c om
public static void generateVerificationInput(final JspWriter writer) throws IOException {
    writer.println("<!-- Score Verification -->");
    writer.println("    <tr>");
    writer.println(
            "      <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font size='4' color='red'>Score entry verified:</font></td>");
    writer.println(
            "      <td><table border='0' cellpadding='0' cellspacing='0' width='150'><tr align='center'>");
    generateYesNoButtons("Verified", writer);
    writer.println("      </tr></table></td>");
    writer.println("      <td colspan='2'>&nbsp;</td>");
    writer.println("      <td class='error' id='verification_error'>&nbsp;</td>");
    writer.println("    </tr>");
}

From source file:fll.web.scoreEntry.ScoreEntry.java

private static void generateEnumeratedGoalButtons(final AbstractGoal goal, final String goalName,
        final JspWriter writer) throws IOException, ParseException {
    writer.println("    <table border='0' cellpadding='0' cellspacing='0' width='100%'>");

    for (final EnumeratedValue valueEle : goal.getSortedValues()) {
        final String valueTitle = valueEle.getTitle();
        final String value = valueEle.getValue();
        final String id = getIDForEnumRadio(goalName, value);
        writer.println("      <tr>");
        writer.println("        <td>");
        writer.println("          <input type='radio' name='" + goalName + "' value='" + value + "' id='" + id
                + "' ' onclick='" + getSetMethodName(goalName) + "(\"" + value + "\")'>");
        writer.println("        </td>");
        writer.println("        <td><label for='" + id + "'/>");
        writer.println("          " + valueTitle);
        writer.println("        </td>");
        writer.println("      </tr>");
    }/*from  w w  w . j  av  a2  s .  com*/

    writer.println("        </table>");

    writer.println("  <td align='right'>");
    writer.println("    <input type='text' name='" + goalName
            + "_radioValue' size='10' align='right' readonly tabindex='-1'>");

}

From source file:fll.web.scoreEntry.ScoreEntry.java

/**
 * Generate a the buttons for a simple goal.
 * /*from  www.j a  v a  2  s. co  m*/
 * @param goalEle
 * @param name
 * @param writer
 * @throws IOException
 * @throws ParseException
 */
private static void generateSimpleGoalButtons(final AbstractGoal goalEle, final String name,
        final JspWriter writer) throws IOException, ParseException {
    // start inc/dec buttons
    writer.println("    <table border='0' cellpadding='0' cellspacing='0' width='150'>");
    writer.println("      <tr align='center'>");

    final double min = goalEle.getMin();
    final double max = goalEle.getMax();
    if (goalEle.isYesNo()) {
        generateYesNoButtons(name, writer);
    } else {
        final double range = max - min;
        final int maxRangeIncrement = (int) Math.floor(range);

        generateIncDecButton(name, -1 * maxRangeIncrement, writer);

        if (FP.greaterThanOrEqual(range, 10, ChallengeParser.INITIAL_VALUE_TOLERANCE)) {
            generateIncDecButton(name, -5, writer);
        } else if (FP.greaterThanOrEqual(range, 5, ChallengeParser.INITIAL_VALUE_TOLERANCE)) {
            generateIncDecButton(name, -3, writer);
        }

        // -1
        generateIncDecButton(name, -1, writer);

        // +1
        generateIncDecButton(name, 1, writer);

        if (FP.greaterThanOrEqual(range, 10, ChallengeParser.INITIAL_VALUE_TOLERANCE)) {
            generateIncDecButton(name, 5, writer);
        } else if (FP.greaterThanOrEqual(range, 5, ChallengeParser.INITIAL_VALUE_TOLERANCE)) {
            generateIncDecButton(name, 3, writer);
        }

        generateIncDecButton(name, maxRangeIncrement, writer);

    }
    writer.println("       </tr>");
    writer.println("    </table>");
    writer.println("  </td>");
    // end inc/dec buttons

    // count
    writer.println("  <td align='right'>");
    if (FP.equals(0, min, ChallengeParser.INITIAL_VALUE_TOLERANCE)
            && FP.equals(1, max, ChallengeParser.INITIAL_VALUE_TOLERANCE)) {
        writer.println("    <input type='text' name='" + name
                + "_radioValue' size='3' align='right' readonly tabindex='-1'>");
    } else {
        // allow these to be editable
        writer.println("    <input type='text' name='" + name + "' size='3' align='right' onChange='"
                + getCheckMethodName(name) + "()'>");
    }
}

From source file:com.wabacus.system.tags.DataImportTag.java

public int doEndTag() throws JspException {
    if (ref == null || ref.trim().equals("")) {
        throw new JspException("<wx:dataimport/>ref");
    }/*w w w. j  ava 2  s .  c o m*/
    BodyContent bc = getBodyContent();
    String label = null;
    if (bc != null)
        label = bc.getString();
    JspWriter out = pageContext.getOut();
    try {
        out.println(TagAssistant.getInstance().getDataImportDisplayValue(ref, this.asyn, this.popupparams,
                this.dataimportinitsize, label, this.interceptor,
                (HttpServletRequest) pageContext.getRequest()));
    } catch (IOException e) {
        log.error("??", e);
    }
    return EVAL_PAGE;
}

From source file:fll.web.scoreEntry.ScoreEntry.java

/**
 * Generate yes and no buttons for goal name.
 *//*from ww  w . j av a  2  s.  c  o m*/
private static void generateYesNoButtons(final String name, final JspWriter writer) throws IOException {
    // generate radio buttons with calls to set<name>

    // order of yes/no buttons needs to match order in generateRefreshBody
    writer.println("        <td>");
    writer.println("          <input type='radio' id='" + name + "_no' name='" + name + "' value='0' onclick='"
            + getSetMethodName(name) + "(0)'>");
    writer.println("          <label for='" + name + "_no'>No</label>");

    writer.println("          &nbsp;&nbsp;");

    writer.println("          <input type='radio' id='" + name + "_yes' name='" + name + "' value='1' onclick='"
            + getSetMethodName(name) + "(1)'>");
    writer.println("          <label for='" + name + "_yes'>Yes</label>");
    writer.println("        </td>");
}

From source file:org.dspace.app.webui.jsptag.CollectionListTag.java

public int doStartTag() throws JspException {
    JspWriter out = pageContext.getOut();

    try {//www .  java 2 s .  c  o m
        out.println("<table align=\"center\" class=\"miscTable\" title=\"Collection List\">");

        // Write column headings
        out.print("<tr><th id=\"t4\" class=\"oddRowOddCol\">" + LocaleSupport.getLocalizedMessage(pageContext,
                "org.dspace.app.webui.jsptag.CollectionListTag.collectionName") + "</th></tr>");

        // Row: toggles between Odd and Even
        String row = "even";

        for (int i = 0; i < collections.length; i++) {
            // name
            String name = collections[i].getMetadata("name");

            // first and only column is 'name'
            out.print("<tr><td headers=\"t4\" class=\"" + row + "RowEvenCol\">");
            out.print("<a href=\"");

            HttpServletRequest hrq = (HttpServletRequest) pageContext.getRequest();
            out.print(hrq.getContextPath() + "/handle/");
            out.print(collections[i].getHandle());
            out.print("\">");
            out.print(name);
            out.print("</a>");

            out.println("</td></tr>");

            row = (row.equals("odd") ? "even" : "odd");
        }

        out.println("</table>");
    } catch (IOException ie) {
        throw new JspException(ie);
    }

    return SKIP_BODY;
}

From source file:org.dspace.app.webui.jsptag.CommunityListTag.java

public int doStartTag() throws JspException {
    JspWriter out = pageContext.getOut();

    try {//  www  .  j  av a  2 s . c om
        out.println("<table align=\"center\" class=\"miscTable\" title=\"Community List\">");

        // Write column headings
        out.print("<tr><th id=\"t5\" class=\"oddRowOddCol\">" + LocaleSupport.getLocalizedMessage(pageContext,
                "org.dspace.app.webui.jsptag.CommunityListTag.communityName") + "</th></tr>");

        // Row: toggles between Odd and Even
        String row = "even";

        for (int i = 0; i < communities.length; i++) {
            // name
            String name = communities[i].getMetadata("name");

            // first and only column is 'name'
            out.print("<tr><td headers=\"t5\" class=\"" + row + "RowEvenCol\">");
            out.print("<a href=\"");

            HttpServletRequest hrq = (HttpServletRequest) pageContext.getRequest();
            out.print(hrq.getContextPath() + "/handle/");
            out.print(communities[i].getHandle());
            out.print("\">");
            out.print(name);
            out.print("</a>");

            out.println("</td></tr>");

            row = (row.equals("odd") ? "even" : "odd");
        }

        out.println("</table>");
    } catch (IOException ie) {
        throw new JspException(ie);
    }

    return SKIP_BODY;
}

From source file:com.wabacus.system.tags.FileUploadTag.java

public int doEndTag() throws JspException {
    BodyContent bc = getBodyContent();//from   ww w.  j a v  a 2s . com
    String label = null;
    if (bc != null)
        label = bc.getString();
    JspWriter out = pageContext.getOut();
    try {
        out.println(TagAssistant.getInstance().getFileUploadDisplayValue(maxsize, allowtypes, disallowtypes,
                uploadcount, newfilename, savepath, rooturl, popupparams, this.initsize, this.interceptor,
                label, this.beforepopup, (HttpServletRequest) pageContext.getRequest()));
    } catch (IOException e) {
        log.error("", e);
    }
    return EVAL_PAGE;
}