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:com.xhsoft.framework.common.page.MiniPageTag.java

/**
 * <p>Description:?</p>//www .  j  a  v a2 s.c om
 * @return void
 * @author wenzhi
 * @version 1.0
 * @exception JspException
 */
private void printOutEnd() throws JspException {
    try {
        JspWriter out = pageContext.getOut();
        String outString = " ";
        out.print(outString);
    } catch (Exception e) {
        throw new JspException(e);
    }
}

From source file:edu.cornell.mannlib.vedit.tags.ErrorTag.java

public int doEndTag() throws JspException {
    try {/*from   w w  w . j  ava2  s .co m*/
        JspWriter out = pageContext.getOut();

        String errors = null;
        try {
            errors = (String) getFormObject().getErrorMap().get(name);
        } catch (Exception e) {
            System.out.println("Could not get the form object from which to extract validation error message.");
        }

        if (errors != null) {
            out.print(StringEscapeUtils.escapeHtml((String) errors));
        }

    } catch (Exception ex) {
        throw new JspException(ex.getMessage());
    }
    return SKIP_BODY;
}

From source file:com.feilong.taglib.util.TagUtils.java

/**
 * Write the specified text as the response to the writer associated with the body content for the tag within which we are currently
 * nested./*from   w w w.  j a va 2 s .co  m*/
 *
 * @param pageContext
 *            The PageContext object for this page
 * @param text
 *            The text to be written
 * @throws UncheckedIOException
 *             the unchecked io exception
 */
public void writePrevious(PageContext pageContext, String text) throws UncheckedIOException {
    JspWriter writer = pageContext.getOut();
    if (writer instanceof BodyContent) {
        writer = ((BodyContent) writer).getEnclosingWriter();
    }
    try {
        writer.print(text);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}

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

/**
 * Render the current div/*w  w  w . j a  va  2 s. c  o m*/
 */
private void renderDiv(final Menu menu, final int index, final String divId) throws IOException, JspException {
    final JspWriter out = pageContext.getOut();
    final String className = getClassName(menu);
    out.print("<li id='" + divId + "'class='" + className + "'");
    String url = menu.getUrl();
    if (StringUtils.isNotEmpty(url)) {
        url = StringEscapeUtils.escapeHtml(url);
        if (url.contains("?")) {
            url += "&";
        } else {
            url += "?";
        }
        url += "fromMenu=true";
        out.print(" linkURL=\"" + url + "\"");
        final String confirmationKey = menu.getConfirmationKey();
        if (StringUtils.isNotEmpty(confirmationKey)) {
            out.print(" confirmationMessage=\""
                    + StringEscapeUtils.escapeHtml(messageHelper.message(confirmationKey)) + "\"");
        }
    }
    out.print(">");
    out.print("<span class=\"" + className + "Bullet\"></span>");
    out.print("<span class=\"" + className + "Text\">");
    final String displayName = menu.getLabel();
    out.print(EscapeHTMLTag.escape(displayName, true));
    out.println("</span>");
    if (menu.getParent() == null) {
        out.println("<script>menuCount++;</script>");
    }
}

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

@Override
public int doEndTag() throws JspException {
    try {/* w  ww .  ja  v a  2  s  . c  o m*/
        // Build the options object
        final StringBuilder options = new StringBuilder();
        options.append('{');
        options.append("'singleField':").append(singleField).append(',');
        options.append("'open':").append(open).append(',');
        options.append("'disabled':").append(disabled);
        if (size != null) {
            options.append(",'size':").append(size);
        }
        if (minWidth != null) {
            options.append(",'minWidth':").append(minWidth);
        }
        if (maxWidth != null) {
            options.append(",'maxWidth':").append(maxWidth);
        }
        if (emptyLabelKey != null) {
            emptyLabel = messageHelper.message(emptyLabelKey);
        }
        if (emptyLabel != null) {
            options.append(",'emptyLabel':\"").append(StringEscapeUtils.escapeJavaScript(emptyLabel))
                    .append('"');
        }
        if (onchange != null) {
            options.append(",'onchange':\"").append(StringEscapeUtils.escapeJavaScript(onchange)).append('"');
        }
        options.append('}');

        // Write the rest of the script
        final JspWriter out = pageContext.getOut();
        if (StringUtils.isNotEmpty(varName)) {
            out.print(varName + "=");
        }
        out.println("new MultiDropDown(" + divId + ", '" + name + "', " + divId + ".values, " + options + ")");
        out.println("</script>");
        return EVAL_PAGE;
    } catch (final IOException e) {
        throw new JspException(e);
    } finally {
        release();
    }
}

From source file:com.draagon.meta.web.view.html.DateView.java

/**
 * Draws a date view of the field/*  w w w . java  2  s. c  o  m*/
 */
protected void doDateView(PageContext page, String label, int mode, Date dateVal, Map params)
        throws IOException {
    Calendar c = Calendar.getInstance();

    String emptyString = ViewHelper.getStringParam(params, ATTR_EMPTYVALUE, null);
    if (emptyString == null && hasAttribute(ATTR_EMPTYVALUE)) {
        emptyString = (String) getAttribute(ATTR_EMPTYVALUE);
    }
    if (emptyString != null) {
        setEmptyString(emptyString);
    }

    boolean useZero = (emptyString != null); // ViewHelper.getBooleanParam( params, ATTR_USEZERO, false );

    int year = 0;
    int mon = 0;
    int day = 0;

    if (dateVal != null) {
        c.setTime(dateVal);

        year = c.get(Calendar.YEAR);
        mon = c.get(Calendar.MONTH) + 1;
        day = c.get(Calendar.DAY_OF_MONTH);
    } else if (!useZero) {
        year = c.get(Calendar.YEAR);
        mon = c.get(Calendar.MONTH) + 1;
        day = c.get(Calendar.DAY_OF_MONTH);
    }

    // Output the Date Views

    JspWriter out = page.getOut();
    if (mode == WebView.READ) {
        if (year == 0 && mon == 0 && day == 0) {
            out.print("[NO DATE DEFINED]");
        } else {
            doMonthView(page, mode, label + "-mon", mon, params);
            out.print("&nbsp;");

            doDayView(page, mode, label + "-day", day, params);

            if (year > 0) {
                out.print("&nbsp;, ");
                HtmlViewHelper.drawText(page, "" + year, params);
            }
        }
    } else if (mode == WebView.EDIT) {
        //hasEmptyValue = empty;
        out.print("<table border=0 cellspacing=0 cellpadding=0><tr><td>");
        doMonthView(page, mode, label + "-mon", mon, params);
        out.print("</td><td>");
        doDayView(page, mode, label + "-day", day, params);
        out.print("</td><td>");

        c = Calendar.getInstance();
        int defMin = c.get(Calendar.YEAR) - 10;
        int defMax = c.get(Calendar.YEAR) + 30;

        try {
            defMin = Integer.parseInt((String) getAttribute(ATTR_MINRANGE));
        } catch (Exception e) {
        }
        try {
            defMax = Integer.parseInt((String) getAttribute(ATTR_MAXRANGE));
        } catch (Exception e) {
        }

        int min = ViewHelper.getIntParam(params, ATTR_MINRANGE, defMin);
        int max = ViewHelper.getIntParam(params, ATTR_MAXRANGE, defMax);

        //ystem.out.println( "min: " + min + ", max: " + max );

        if (min > 0 || max > 0) {
            doYearView(page, mode, label + "-year", year, min, max, params);
        } else if (year > 0) {
            HtmlViewHelper.drawTextBox(page, label + "-year", "" + year, 4, 4, params);
        } else {
            HtmlViewHelper.drawTextBox(page, label + "-year", "", 4, 4, params);
        }

        out.print("</td></tr></table>");
    } else {
        HtmlViewHelper.drawHidden(page, params);
    }
}

From source file:org.opencms.workplace.administration.A_CmsImportFromHttp.java

/**
 * Performs the dialog actions depending on the initialized action and displays the dialog form.<p>
 * /*w  w w  . j av a2s. co  m*/
 * @throws JspException if dialog actions fail
 * @throws IOException if writing to the JSP out fails, or in case of errors forwarding to the required result page
 * @throws ServletException in case of errors forwarding to the required result page
 */
public void displayDialog() throws IOException, JspException, ServletException {

    switch (getAction()) {

    case ACTION_CANCEL:
        // ACTION: cancel button pressed
        actionCloseDialog();
        break;

    case ACTION_OK:
        // ACTION: ok button pressed
        setParamAction(DIALOG_OK);
        actionCommit();
        if (getException() == null) {
            // file successfully copied to server
            break;
        }

    case ACTION_DEFAULT:
    default:
        // ACTION: show dialog (default)
        setParamAction(DIALOG_OK);
        JspWriter out = getJsp().getJspContext().getOut();
        out.print(defaultActionHtml());
    }
}

From source file:net.ontopia.topicmaps.nav2.taglibs.logic.ForEachTag.java

/**
 * Actions after some body has been evaluated.
 *//*from w ww . j a v  a2s. c  o  m*/
public int doAfterBody() throws JspTagException {
    // put out the evaluated body
    BodyContent body = getBodyContent();
    JspWriter out = body.getEnclosingWriter();
    try {
        out.print(body.getString());
    } catch (IOException ioe) {
        throw new NavigatorRuntimeException("Error in ForEachTag.", ioe);
    }
    // Clear for next evaluation
    body.clearBody();

    //log.debug("doAfterBody, itemsSize: " + items.length + ", index: " + index);

    // test if we have to repeat the body 
    if (index < items.length && index < maxNumber) {

        // insert separating string
        if (separator != null) {
            try {
                out.print(separator);
            } catch (IOException ioe) {
                throw new NavigatorRuntimeException("Error in ForEachTag.", ioe);
            }
        }
        // set to next value in set
        setVariableValues(items[index]);
        index++;
        return EVAL_BODY_AGAIN;
    } else {
        return SKIP_BODY;
    }

}

From source file:org.opencms.workplace.galleries.CmsAjaxLinkGallery.java

/**
 * Writes the current link into the pointer resource. <p>
 * //from   w  w w .  java  2 s  . c om
 * @see org.opencms.workplace.galleries.CmsAjaxLinkGallery#changeItemLinkUrl(String)
 * 
 * @param itemUrl the pointer resource to change the link of 
 * 
 */
@Override
protected void changeItemLinkUrl(String itemUrl) {

    try {
        JspWriter out = getJsp().getJspContext().getOut();
        if (getCms().existsResource(itemUrl)) {
            try {
                writePointerLink(getCms().readResource(itemUrl));
                out.print(buildJsonItemObject(getCms().readResource(itemUrl)));
            } catch (CmsException e) {
                // can not happen in theory, because we used existsResource() before...
            }
        } else {
            out.print(RETURNVALUE_NONE);
        }
    } catch (IOException e) {
        if (LOG.isErrorEnabled()) {
            LOG.error(e.getLocalizedMessage(), e);
        }
    }

}

From source file:org.ecside.tag.form.ECSideFormTag.java

 public int doAfterBody() {
   BodyContent body = getBodyContent();/*  ww  w. j  a  va 2s .co m*/
   try    {
      JspWriter out = body.getEnclosingWriter();
      String bodytext = body.getString();
      if ((beansValues != null) && (beansValues.size() > 0)) {
         bodytext = populateForm(bodytext, beansValues);
      }
      out.print(bodytext);
   } catch (Exception ex) {
      LogHandler.errorLog(logger, ex);
   }
   return SKIP_BODY;
}