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:fll.web.scoreEntry.ScoreEntry.java

/**
 * Generate the score entry form./*from w w  w  .ja  va2 s  .co  m*/
 */
public static void generateScoreEntry(final JspWriter writer, final ServletContext application)
        throws IOException {
    final ChallengeDescription description = ApplicationAttributes.getChallengeDescription(application);
    final Formatter formatter = new Formatter(writer);

    String prevCategory = null;
    final PerformanceScoreCategory performanceElement = description.getPerformance();
    for (final AbstractGoal goalEle : performanceElement.getGoals()) {
        final String name = goalEle.getName();
        final String title = goalEle.getTitle();
        final String category = goalEle.getCategory();

        try {

            if (!StringUtils.equals(prevCategory, category)) {
                writer.println("<tr><td colspan='5'>&nbsp;</td></tr>");
                if (!StringUtils.isEmpty(category)) {
                    writer.println("<tr><td colspan='5' class='center'><b>" + category + "</b></td></tr>");
                }
            }

            writer.println("<!-- " + name + " -->");
            writer.println("<tr>");
            writer.println("  <td>");
            writer.println("    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font size='3'><b>" + title + ":</b></font>");
            writer.println("  </td>");

            if (goalEle.isComputed()) {
                writer.println("  <td colspan='2' align='center'><b>Computed Goal</b></td>");
            } else {
                if (goalEle.isEnumerated()) {
                    // enumerated
                    writer.println("  <td>");
                    generateEnumeratedGoalButtons(goalEle, name, writer);
                    writer.println("  </td>");
                } else {
                    writer.println("  <td>");
                    generateSimpleGoalButtons(goalEle, name, writer);
                    writer.println("  </td>");
                } // end simple goal
            } // goal

            // computed score
            writer.println("  <td align='right'>");
            writer.println("    <input type='text' name='score_" + name
                    + "' size='3' align='right' readonly tabindex='-1'>");
            writer.println("  </td>");

            // error message
            formatter.format("  <td class='error score-error' id='error_%s'>&nbsp;</td>%n", name);

            writer.println("</tr>");
            writer.println("<!-- end " + name + " -->");
            writer.newLine();
        } catch (final ParseException pe) {
            throw new RuntimeException("FATAL: min/max not parsable for goal: " + name);
        }

        prevCategory = category;
    } // end foreach child of performance
}

From source file:com.camel.framework.tag.ScriptTag.java

/**
 * ?? Minify?script??/*from  ww w .jav  a2  s .co  m*/
 * 
 * @param sb
 * @param resourcesUrl
 * @param out
 */
private void parseToMinifyStyle(StringBuffer sb, String resourcesUrl, JspWriter out) {
    sb.setLength(0);
    sb.append("<script type='").append(type).append("' data-config='").append(data_config)
            .append("' data-main='").append(data_main).append("' src='").append(resourcesUrl).append("min/?");

    // path?b
    if (StringUtils.isNotBlank(path)) {
        sb.append("b=").append(path).append("&");
    }

    sb.append("f=").append(src).append("'></script>");

    try {
        // ??script?
        out.println(sb.toString());

    } catch (IOException e) {
        logger.error("Could not print out value '" + sb.toString(), e);
    }
}

From source file:com.camel.framework.tag.CssLinkTag.java

/**
 * ??? Minify?link??/*ww w .j av a 2s. c  o m*/
 * 
 * @param sb
 * @param out
 */
private void parseToConventionalStyle(StringBuffer sb, String resourcesUrl, JspWriter out) {

    // css???
    String[] hrefArray = href.split(ITagBasic.SEPARATOR_COMMA);

    for (String hrefStr : hrefArray) {
        sb.setLength(0);
        sb.append("<link type='").append(type).append("' rel='").append(rel).append("' href='")
                .append(resourcesUrl);

        if (StringUtils.isNotBlank(path)) {
            sb.append(path).append("/");
        }

        sb.append(hrefStr.trim()).append("'/>");

        try {
            // ?
            out.println(sb.toString());

        } catch (IOException e) {
            logger.error("Could not print out value '" + sb.toString(), e);
        }
    }

}

From source file:it.scoppelletti.wui.HeadTag.java

/**
 * Emette il contributo di un&rsquo;applicazione all&rsquo;elemento
 * <CODE>&lt;head&gt;</CODE>.
 * // ww w  .  ja v a2 s  .c o m
 * @param uri    Risorsa REST.
 * @param writer Flusso di scrittura.
 */
private void head(URI uri, JspWriter writer) throws IOException {
    String line;
    ClientResource clientRes;
    Representation rep;
    InputStream in = null;
    Reader reader = null;
    BufferedReader lineReader = null;

    clientRes = new ClientResource(uri);
    rep = clientRes.get(MediaType.TEXT_HTML);
    if (rep == null) {
        return;
    }

    try {
        in = rep.getStream();
        reader = new InputStreamReader(in);
        in = null;
        lineReader = new BufferedReader(reader);
        reader = null;

        line = lineReader.readLine();
        while (line != null) {
            writer.println(line);
            line = lineReader.readLine();
        }
    } finally {
        if (in != null) {
            IOUtils.close(in);
            in = null;
        }
        if (reader != null) {
            IOUtils.close(reader);
            reader = null;
        }
        if (lineReader != null) {
            IOUtils.close(lineReader);
            lineReader = null;
        }
    }
}

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

/**
 * Writes the buttons with supported languages
 *
 * @param languages// w ww.  j a  v  a2 s  .  c o  m
 * @throws IOException
 */
private void writeLanguageOptions(JspWriter out, List<String> languages) throws IOException {
    for (String language : languages) {
        // <a data-l10n-lang="EN" href="javascript:;" >EN</a> 
        out.print("<a data-l10n-lang=\"");
        out.print(language);
        out.print("\" href=\"javascript:;\"");

        // If it is the active language, add the active style
        if (getDefaultLanguage().equals(language)) {
            out.print(" class=\"l10n-active\"");
        }

        out.print(">");
        out.print(language.toUpperCase());
        out.println("</a>");
    }
}

From source file:org.sparkcommerce.core.web.catalog.taglib.GoogleAnalyticsTag.java

@Override
public void doTag() throws JspException, IOException {
    JspWriter out = getJspContext().getOut();
    String webPropertyId = getWebPropertyId();

    if (webPropertyId == null) {
        ServletContext sc = ((PageContext) getJspContext()).getServletContext();
        ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(sc);
        context.getAutowireCapableBeanFactory().autowireBeanProperties(this,
                AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, false);
    }// ww  w  .j av  a  2 s  . co m

    if (webPropertyId.equals("UA-XXXXXXX-X")) {
        LOG.warn(
                "googleAnalytics.webPropertyId has not been overridden in a custom property file. Please set this in order to properly use the Google Analytics tag");
    }

    out.println(analytics(webPropertyId, order));
    super.doTag();
}

From source file:org.broadleafcommerce.core.web.catalog.taglib.GoogleAnalyticsTag.java

@Override
public void doTag() throws JspException, IOException {
    JspWriter out = getJspContext().getOut();

    if (this.webPropertyId == null) {
        ServletContext sc = ((PageContext) getJspContext()).getServletContext();
        ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(sc);
        context.getAutowireCapableBeanFactory().autowireBeanProperties(this,
                AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, false);
    }/*from   w w w  .j a  va  2 s .  com*/

    String webPropertyId = getWebPropertyId();

    if (webPropertyId.equals("UA-XXXXXXX-X")) {
        LOG.warn(
                "googleAnalytics.webPropertyId has not been overridden in a custom property file. Please set this in order to properly use the Google Analytics tag");
    }

    out.println(analytics(webPropertyId, order));
    super.doTag();
}

From source file:org.broadleafcommerce.core.web.catalog.taglib.SearchFilterItemTag.java

private void doSliderRange(JspWriter out) throws JspException, IOException {
    List<Product> products = ((SearchFilterTag) getParent()).getProducts();

    Money min = null;/*from ww w .j  av a 2s.  c o m*/
    Money max = null;
    BeanToPropertyValueTransformer valueTransformer = new BeanToPropertyValueTransformer(property, true);

    for (Product product : products) {
        Money propertyObject = (Money) valueTransformer.transform(product);
        if (propertyObject == null) {
            min = new Money(0D);
            max = new Money(0D);
        } else {
            min = propertyObject.min(min);
            max = propertyObject.max(max);
        }
    }

    String propertyCss = property.replaceAll("[.\\[\\]]", "_");

    out.println("<div id='searchFilter-" + propertyCss + "'></div>");
    out.println("Range:");
    out.println("<input type=\"text\" id=\"min-" + propertyCss + "\" name='min-" + property + "' value='"
            + min.getCurrency().getSymbol() + min.getAmount().toPlainString() + "'/> - ");
    out.println("<input type=\"text\" id=\"max-" + propertyCss + "\" name='max-" + property + "' value='"
            + max.getCurrency().getSymbol() + max.getAmount().toPlainString() + "'/> <br/>");

    out.println("        <script type=\"text/javascript\">\r\n" + "        $(function() {\r\n"
            + "            $(\"#searchFilter-" + propertyCss + "\").slider({\r\n"
            + "                range: true,\r\n" + "                min: " + min.getAmount().toPlainString()
            + ", max: " + max.getAmount().toPlainString() + "," + "                values: ["
            + min.getAmount().toPlainString() + "," + max.getAmount().toPlainString() + "],"
            + "                slide: function(event, ui) {\r\n" + "                    $(\"#min-" + propertyCss
            + "\").val('" + min.getCurrency().getSymbol() + "' + ui.values[0] );\r\n"
            + "                    $(\"#max-" + propertyCss + "\").val('" + max.getCurrency().getSymbol()
            + "' + ui.values[1]);\r\n" + "                }\r\n" + "            });\r\n" + "        });\r\n"
            + "        $('#searchFilter-" + propertyCss
            + "').bind('slidechange',  updateSearchFilterResults); \r\n" + "        </script>");
}

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

/**
 * Displays the opening of the TD tag and prepares it for
 * displaying the body contents.//from w  w w  .  ja v a 2 s.  c  o m
 * @param out JspWriter to write to.
 * @param parent Containing JspTag.
 * @throws IOException if an error occurs writing to the JspWriter.
 */
protected void renderData(JspWriter out, UnpagedListDisplayTag parent) throws IOException {
    String nodeIdString = parent.getNodeIdString();

    // Deal with structural markup before we get to this <td>
    if (parent.getColumnCount() == 0 && parent.getCurrRow() == 0) {
        out.println("</thead><tbody>");

    }
    setupAttribute(td, "width", getWidth());
    setupAttribute(td, "colspan", getColspan());
    if (getNowrap() != null && getNowrap().equals("true")) {
        setupAttribute(td, "nowrap", "nowrap");
    }

    // Only one column
    if (parent.getNumberOfColumns() == 1) {
        setupAttribute(td, "class", "first-column last-column");
    }
    // Are we the first column?
    else if (parent.getColumnCount() == 0) {
        setupAttribute(td, "class", "first-column");
    }
    // Are we the last column?
    else if (parent.getColumnCount() == parent.getNumberOfColumns() - 1) {
        setupAttribute(td, "class", "last-column");
    }
    // Are we a middle column?
    else {
        setupAttribute(td, "class", getCssClass());
    }

    parent.incrColumnCount();

    if (parent.getType().equals("treeview") && parent.isChild(nodeIdString)) {
        setupAttribute(td, "style", getStyle() + "display: none;");
    } else {
        setupAttribute(td, "style", getStyle());
    }

    out.print(td.renderOpenTag());

    if (parent.getType().equals("treeview") && parent.isParent(nodeIdString) && parent.getColumnCount() == 1) {
        out.print("<a onclick=\"toggleRowVisibility('" + parent.createIdString(nodeIdString) + "');\" "
                + "style=\"cursor: pointer;\">" + "<img name=\"" + parent.createIdString(nodeIdString)
                + "-image\" src=\"/img/list-expand.gif\" alt=\""
                + LocalizationService.getInstance().getMessage("channels.parentchannel.alt") + "\"/></a>");
        parent.setCurrRow(parent.getCurrRow() + 1);
    }

    if (showUrl()) {
        setupAttribute(href, "href", getUrl());
        out.print(href.renderOpenTag());
    }
}

From source file:com.camel.framework.tag.ScriptTag.java

/**
 * ???script??/*from   ww  w  . j a v  a2s  . com*/
 * 
 * @param sb
 * @param out
 */
private void parseToConventionalStyle(StringBuffer sb, String resourcesUrl, JspWriter out) {
    // js???
    String[] srcArray = src.split(ITagBasic.SEPARATOR_COMMA);

    for (String srcStr : srcArray) {
        // 
        sb.setLength(0);
        // ?script
        sb.append("<script type='").append(type).append("' data-config='").append(data_config)
                .append("' data-main='").append(data_main).append("' src='").append(resourcesUrl);

        // path ??
        if (StringUtils.isNotBlank(path)) {
            sb.append(path).append("/");
        }

        sb.append(srcStr.trim()).append("'></script>");

        try {
            // ??script?
            out.println(sb.toString());

        } catch (IOException e) {
            logger.error("Could not print out value '" + sb.toString(), e);
        }
    }
}