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:org.dspace.app.webui.jsptag.SelectGroupTag.java

public int doStartTag() throws JspException {
    try {// w w w.j  a v  a2  s. c o  m
        JspWriter out = pageContext.getOut();
        HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();

        out.print(
                "<table><tr><td colspan=\"2\" align=\"center\"><select multiple=\"multiple\" name=\"group_ids\" size=\"");
        out.print(multiple ? "10" : "1");
        out.println("\">");

        //ensure that if no group is selected that a blank option is displayed - xhtml compliance 
        if (groups == null || groups.length == 0) {
            out.print("<option value=\"\">&nbsp;</option>");
        }

        if (groups != null) {
            for (int i = 0; i < groups.length; i++) {
                out.print("<option value=\"" + groups[i].getID() + "\">");
                out.print(groups[i].getName() + " (" + groups[i].getID() + ")");
                out.println("</option>");
            }
        }

        out.print("</select></td>");

        if (multiple) {
            out.print("</tr><tr><td width=\"50%\" align=\"center\">");
        } else {
            out.print("<td>");
        }

        String p = (multiple
                ? LocaleSupport.getLocalizedMessage(pageContext,
                        "org.dspace.app.webui.jsptag.SelectGroupTag.selectGroups")
                : LocaleSupport.getLocalizedMessage(pageContext,
                        "org.dspace.app.webui.jsptag.SelectGroupTag.selectGroup"));
        out.print("<input type=\"button\" value=\"" + p + "\" onclick=\"javascript:popup_window('"
                + req.getContextPath() + "/tools/group-select-list?multiple=" + multiple
                + "', 'group_popup');\" />");

        if (multiple) {
            out.print("</td><td width=\"50%\" align=\"center\">");
            out.print("<input type=\"button\" value=\""
                    + LocaleSupport.getLocalizedMessage(pageContext,
                            "org.dspace.app.webui.jsptag.SelectGroupTag.removeSelected")
                    + "\" onclick=\"javascript:removeSelected(window.document.epersongroup.group_ids);\"/>");
        }

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

    return SKIP_BODY;
}

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

public int doStartTag() throws JspException {
    try {//  ww  w  .  j  a va 2 s .co m
        JspWriter out = pageContext.getOut();
        HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();

        out.print(
                "<table><tr><td colspan=\"2\" align=\"center\"><select multiple=\"multiple\" name=\"eperson_id\" size=\"");
        out.print(multiple ? "10" : "1");
        out.println("\">");
        // ensure that if no eperson is selected that a blank option is displayed - xhtml compliance 
        if (epeople == null || epeople.length == 0) {
            out.print("<option value=\"\">&nbsp;</option>");
        }

        if (epeople != null) {
            for (int i = 0; i < epeople.length; i++) {
                out.print("<option value=\"" + epeople[i].getID() + "\">");
                out.print(epeople[i].getFullName() + " (" + epeople[i].getEmail() + ")");
                out.println("</option>");
            }
        }
        // add blank option value if no person selected to ensure that code is xhtml compliant 
        //out.print("<option/>");
        out.print("</select></td>");

        if (multiple) {
            out.print("</tr><tr><td width=\"50%\" align=\"center\">");
        } else {
            out.print("<td>");
        }

        String p = (multiple
                ? LocaleSupport.getLocalizedMessage(pageContext,
                        "org.dspace.app.webui.jsptag.SelectEPersonTag.selectPeople")
                : LocaleSupport.getLocalizedMessage(pageContext,
                        "org.dspace.app.webui.jsptag.SelectEPersonTag.selectPerson"));
        out.print("<input type=\"button\" value=\"" + p + "\" onclick=\"javascript:popup_window('"
                + req.getContextPath() + "/tools/eperson-list?multiple=" + multiple
                + "', 'eperson_popup');\" />");

        if (multiple) {
            out.print("</td><td width=\"50%\" align=\"center\">");
            out.print("<input type=\"button\" value=\""
                    + LocaleSupport.getLocalizedMessage(pageContext,
                            "org.dspace.app.webui.jsptag.SelectEPersonTag.removeSelected")
                    + "\" onclick=\"javascript:removeSelected(window.document.epersongroup.eperson_id);\"/>");
        }

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

    return SKIP_BODY;
}

From source file:nl.strohalm.cyclos.taglibs.MultiDropDownTag.java

@Override
@SuppressWarnings("unchecked")
public int doStartTag() throws JspException {
    divId = "_container_" + System.currentTimeMillis() + "_" + new Random().nextInt(Integer.MAX_VALUE);

    if (selectedValues == null) {
        try {/*from w w w .  j  a v  a 2  s .c  om*/
            final Object form = pageContext.findAttribute(Constants.BEAN_KEY);
            selectedValues = CoercionHelper.coerce(List.class, PropertyHelper.get(form, name));
            for (int i = 0; i < selectedValues.size(); i++) {
                selectedValues.set(i, CoercionHelper.coerce(String.class, selectedValues.get(i)));
            }
        } catch (final Exception e) {
            // Leave selected values empty
        }
    }

    try {
        final JspWriter out = pageContext.getOut();
        out.print("<div");
        if (maxWidth != null) {
            out.print(" style='width:" + maxWidth + "px'");
        }
        out.println(" id='" + divId + "'></div>");
        // Write the start of the script
        out.println("<script>");
        out.println("var mddNoItemsMessage = \""
                + StringEscapeUtils.escapeJavaScript(messageHelper.message("multiDropDown.noItemsMessage"))
                + "\";");
        out.println("var mddSingleItemsMessage = \""
                + StringEscapeUtils.escapeJavaScript(messageHelper.message("multiDropDown.singleItemMessage"))
                + "\";");
        out.println("var mddMultiItemsMessage = \""
                + StringEscapeUtils.escapeJavaScript(messageHelper.message("multiDropDown.multiItemsMessage"))
                + "\";");

        out.println("var " + divId + " = $('" + divId + "');");
        out.println(divId + ".values = [];");
    } catch (final IOException e) {
        throw new JspException(e);
    }

    return EVAL_BODY_INCLUDE;
}

From source file:org.kuali.mobility.tags.LocalisedFieldTag.java

/**
 * Writes the HTML input field for the specified language
 *
 * @param out/*from   w w  w.  jav a  2 s. co  m*/
 * @param language
 * @throws IOException
 */
private void writeInput(JspWriter out, String language) throws IOException {
    String value = getMessage(code, language);
    if (value == null) {
        value = "";
    }

    if (INPUT_TEXT.equals(this.inputType)) {
        out.println("<input type=\"text\" name=\"" + name + "." + language + "\" value=\"" + value + "\" />");
    } else if (INPUT_TEXT_AREA.equals(this.inputType)) {
        out.println("<textarea rows=\"8\" cols=\"80\" name=\"" + name + "." + language + "\">");
        out.println(value);
        out.println("</textarea>");
    } else {
        throw new IllegalArgumentException("You specified an invalid input type : " + inputType);
    }
}

From source file:com.glaf.jbpm.tag.JbpmProcessImageTag.java

private void writeTable() throws IOException, DocumentException {
    int borderWidth = 4;
    Element rootDiagramElement = DocumentHelper.parseText(new String(gpdBytes)).getRootElement();
    int[] boxConstraint;
    int[] imageDimension = extractImageDimension(rootDiagramElement);
    String imagePath = contextPath + "/mx/jbpm/image";
    if (conf.get("jbpm.processImageUrl") != null) {
        imagePath = contextPath + conf.get("jbpm.processImageUrl");
    }// w ww .  j  a  va2  s  . c o  m
    String imageLink = imagePath + "?processDefinitionId=" + processDefinition.getId();
    JspWriter jspOut = pageContext.getOut();

    if (tokenInstanceId > 0) {
        List<Token> allTokens = new java.util.ArrayList<Token>();
        walkTokens(currentToken, allTokens);
        jspOut.println("<div style='position:relative; background-image:url(" + imageLink
                + ");background-repeat:no-repeat; width: " + imageDimension[0] + "px; height: "
                + imageDimension[1] + "px;'>");

        for (int i = 0; i < allTokens.size(); i++) {
            Token token = allTokens.get(i);
            if (!token.getProcessInstance().hasEnded()) {
                if (!token.isAbleToReactivateParent()) {
                    continue;
                }
            }
            // check how many tokens are on teh same level (= having the
            // same parent)
            int offset = i;
            if (i > 0) {
                while (offset > 0 && (allTokens.get(offset - 1)).getParent().equals(token.getParent())) {
                    offset--;
                }
            }
            boxConstraint = extractBoxConstraint(rootDiagramElement, token);

            // Adjust for borders
            // boxConstraint[2] -= borderWidth * 2;
            // boxConstraint[3] -= borderWidth * 2;

            jspOut.println("<div style='position:absolute; left: " + boxConstraint[0] + "px; top: "
                    + boxConstraint[1] + "px; ");

            if (i == (allTokens.size() - 1)) {
                jspOut.println("border: " + currentTokenColor);
            } else {
                if (StringUtils.isNotEmpty(childTokenColor)) {
                    jspOut.println("border: " + childTokenColor);
                }
            }

            jspOut.println(" " + borderWidth + "px groove; " + "width: " + (boxConstraint[2] - 2)
                    + "px; height: " + (boxConstraint[3] - 2) + "px;'>");

            jspOut.println("</div>");
        }
        jspOut.println("</div>");
    } else {
        boxConstraint = extractBoxConstraint(rootDiagramElement);

        jspOut.println("<table border=0 cellspacing=0 cellpadding=0 width=" + imageDimension[0] + " height="
                + imageDimension[1] + ">");
        jspOut.println("  <tr>");
        jspOut.println("    <td width=" + imageDimension[0] + " height=" + imageDimension[1]
                + " style=\"background-image:url(" + imageLink + ")\" valign=top>");
        jspOut.println("      <table border=0 cellspacing=0 cellpadding=0>");
        jspOut.println("        <tr>");
        jspOut.println("          <td width=" + (boxConstraint[0] - borderWidth) + " height="
                + (boxConstraint[1] - borderWidth) + " style=\"background-color:transparent;\"></td>");
        jspOut.println("        </tr>");
        jspOut.println("        <tr>");
        jspOut.println("          <td style=\"background-color:transparent;\"></td>");
        jspOut.println("          <td style=\"border-color:" + currentTokenColor + "; border-width:"
                + borderWidth + "px; border-style:groove; background-color:transparent;\" width="
                + boxConstraint[2] + " height=" + (boxConstraint[3] + (2 * borderWidth)) + ">&nbsp;</td>");
        jspOut.println("        </tr>");
        jspOut.println("      </table>");
        jspOut.println("    </td>");
        jspOut.println("  </tr>");
        jspOut.println("</table>");
    }
}

From source file:com.trenako.web.tags.BreadcrumbTags.java

@Override
protected int writeTagContent(JspWriter out, String contextPath) throws JspException {

    if (getCriteria().isEmpty()) {
        return Tag.SKIP_BODY;
    }//  w  w  w. jav  a 2  s .c om

    try {
        List<HtmlTag> items = new ArrayList<HtmlTag>();
        for (Criteria crit : getCriteria().criteria()) {
            addElement(items, contextPath, crit);
        }

        HtmlTag list = ul(tags(items)).cssClass("breadcrumb");
        out.println(list.toString());

    } catch (IOException e) {
        throw new JspException(e);
    }

    return Tag.SKIP_BODY;
}

From source file:com.redhat.rhn.frontend.taglibs.UnpagedListDisplayTag.java

/** {@inheritDoc} */
public int doAfterBody() throws JspException {
    JspWriter out = null;
    try {/*from w ww .j av a  2  s  .  co  m*/
        out = pageContext.getOut();

        if (pageContext.getAttribute("current") == null) {
            out.println("</tr>");
            out.println("</thead>");
            out.println("<tbody>");
        } else {
            out.println("</tr>");
        }

        if (getIterator().hasNext()) {
            setColumnCount(0);
            Object next = getIterator().next();
            out.println(getTrElement(next, currRow++));
            pageContext.setAttribute("current", next);
            return EVAL_BODY_AGAIN;
        }
    } catch (IOException e) {
        throw new JspException("Error while writing to JSP: " + e.getMessage());
    }

    return SKIP_BODY;
}

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 www  .j  a  va2 s.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:org.neuro4j.web.taglib.IncludeTagHandler.java

private void processIncludeRequest(String url, JspWriter out) {

    BufferedReader dis = null;/*from ww  w  .j av a2s . c o m*/
    try {

        URLConnection connection = new URL(url).openConnection();

        connection.setRequestProperty("Accept-Charset", charset);

        dis = new BufferedReader(new InputStreamReader(connection.getInputStream()));

        String inputLine;

        while ((inputLine = dis.readLine()) != null) {
            out.println(inputLine);
        }

    } catch (MalformedURLException me) {
        System.err.println("MalformedURLException: " + me);
    } catch (IOException ioe) {
        System.err.println("IOException: " + ioe);
    } finally {
        if (dis != null) {
            try {
                dis.close();
            } catch (IOException e) {
            }
        }

    }

}

From source file:edu.cornell.mannlib.vitro.webapp.web.jsptags.OptionsForClassTag.java

public int doStartTag() {
    try {//from  w w  w.  j a  v  a 2 s .c o  m
        VitroRequest vreq = new VitroRequest((HttpServletRequest) pageContext.getRequest());
        WebappDaoFactory wdf = vreq.getWebappDaoFactory();
        if (wdf == null)
            throw new Exception("could not get WebappDaoFactory from request.");

        VClass vclass = wdf.getVClassDao().getVClassByURI(getClassUri());
        if (vclass == null)
            throw new Exception("could not get class for " + getClassUri());

        List<Individual> individuals = wdf.getIndividualDao().getIndividualsByVClassURI(vclass.getURI(), -1,
                -1);

        JspWriter out = pageContext.getOut();

        for (Individual ind : individuals) {
            String uri = ind.getURI();
            if (uri != null) {
                out.print("<option value=\"" + StringEscapeUtils.escapeHtml(uri) + '"');
                if (uri.equals(getSelectedUri()))
                    out.print(" selected=\"selected\"");
                out.print('>');
                out.print(StringEscapeUtils.escapeHtml(ind.getName()));
                out.println("</option>");
            }

        }
    } catch (Exception ex) {
        throw new Error("Error in doStartTag: " + ex.getMessage());
    }
    return SKIP_BODY;
}