Search in sources :

Example 91 with JspWriter

use of javax.servlet.jsp.JspWriter in project com.revolsys.open by revolsys.

the class ScriptsTag method writeScripts.

/**
 * Write out the HTML tags for each script.
 *
 * @param scripts The scripts.
 * @throws IOException If there was an error writing the scripts.
 */
private void writeScripts(final Collection scripts) throws IOException {
    final JspWriter out = this.pageContext.getOut();
    for (final Iterator scriptIter = scripts.iterator(); scriptIter.hasNext(); ) {
        final Script script = (Script) scriptIter.next();
        final String content = script.getContent();
        if (content != null) {
            out.print("<script type=\"");
            out.print(script.getType());
            out.println("\">");
            out.println(content);
            out.println("</script>");
        } else {
            out.print("<script src=\"");
            out.print(script.getFile());
            out.print("\" type=\"");
            out.print(script.getType());
            out.println("\">\n</script>");
        }
    }
}
Also used : Script(com.revolsys.ui.html.view.Script) Iterator(java.util.Iterator) JspWriter(javax.servlet.jsp.JspWriter)

Example 92 with JspWriter

use of javax.servlet.jsp.JspWriter in project com.revolsys.open by revolsys.

the class AbstractElementTag method doTag.

/**
 * Process the tag.
 *
 * @throws JspException If there was an exception processing the tag.
 * @throws IOException If an i/o error occurs.
 */
@Override
public void doTag() throws JspException, IOException {
    try {
        final JspContext jspContext = getJspContext();
        final JspWriter out = jspContext.getOut();
        final ExpressionEvaluator expressionEvaluator = jspContext.getExpressionEvaluator();
        final Collection elements = (Collection) expressionEvaluator.evaluate(this.elementExpression, Collection.class, jspContext.getVariableResolver(), null);
        if (elements != null) {
            serializeElements(out, elements);
        }
    } catch (final Throwable t) {
        log.error(t.getMessage(), t);
        throw new JspTagException(t.getMessage(), t);
    }
}
Also used : JspContext(javax.servlet.jsp.JspContext) Collection(java.util.Collection) JspWriter(javax.servlet.jsp.JspWriter) ExpressionEvaluator(javax.servlet.jsp.el.ExpressionEvaluator)

Example 93 with JspWriter

use of javax.servlet.jsp.JspWriter in project com.revolsys.open by revolsys.

the class AbstractMapElementTag method doTag.

/**
 * Process the tag.
 *
 * @throws JspException If there was an exception processing the tag.
 * @throws IOException If an i/o error occurs.
 */
@Override
public void doTag() throws JspException, IOException {
    try {
        final JspContext jspContext = getJspContext();
        final JspWriter out = jspContext.getOut();
        final ExpressionEvaluator expressionEvaluator = jspContext.getExpressionEvaluator();
        final Object t = expressionEvaluator.evaluate(this.mapExpression, Object.class, jspContext.getVariableResolver(), null);
        if (t instanceof Map) {
            final Map map = (Map) t;
            if (map != null) {
                final Object object = map.get(this.key);
                serializeObject(out, object);
            }
        } else {
            log.debug(t);
        }
    } catch (final Throwable t) {
        log.error(t.getMessage(), t);
        throw new JspTagException(t.getMessage(), t);
    }
}
Also used : JspContext(javax.servlet.jsp.JspContext) JspWriter(javax.servlet.jsp.JspWriter) ExpressionEvaluator(javax.servlet.jsp.el.ExpressionEvaluator) Map(java.util.Map)

Example 94 with JspWriter

use of javax.servlet.jsp.JspWriter in project jforum2 by rafaelsteil.

the class TrailTag method doWikiStartTag.

/**
 * @see com.ecyrd.jspwiki.tags.WikiTagBase#doWikiStartTag()
 */
public final int doWikiStartTag() throws IOException {
    HttpSession session = pageContext.getSession();
    FixedQueue trail = (FixedQueue) session.getAttribute(BREADCRUMBTRAIL_KEY);
    String page = m_wikiContext.getPage().getName();
    if (trail == null) {
        trail = new FixedQueue(maxPages);
    }
    if (m_wikiContext.getRequestContext().equals(WikiContext.VIEW)) {
        if (trail.isEmpty()) {
            trail.push(page);
        } else {
            // Don't add the page to the queue if the page was just refreshed
            if (!((String) trail.getLast()).equals(page)) {
                if (trailType.equalsIgnoreCase("visit")) {
                    if (!trail.contains(page)) {
                        trail.push(page);
                    }
                } else {
                    trail.push(page);
                }
            }
        }
    }
    // our trail
    session.setAttribute(BREADCRUMBTRAIL_KEY, trail);
    JspWriter out = pageContext.getOut();
    int queueSize = trail.size();
    String linkClass = "wikipage";
    WikiEngine engine = m_wikiContext.getEngine();
    int i = 0;
    for (Iterator iter = trail.iterator(); iter.hasNext(); i++) {
        String currentPage = (String) iter.next();
        StringBuffer sb = new StringBuffer(128).append("<a class='").append(linkClass).append("' href='").append(engine.getViewURL(currentPage)).append("'>");
        if (currentPage == page) {
            sb.append("<b>").append(currentPage).append("</b>");
        } else {
            sb.append(currentPage);
        }
        sb.append("</a>");
        out.print(sb.toString());
        if (i + 1 < queueSize) {
            out.print(trailSeparator);
        }
    }
    return SKIP_BODY;
}
Also used : HttpSession(javax.servlet.http.HttpSession) Iterator(java.util.Iterator) JspWriter(javax.servlet.jsp.JspWriter) WikiEngine(com.ecyrd.jspwiki.WikiEngine)

Example 95 with JspWriter

use of javax.servlet.jsp.JspWriter in project acs-aem-commons by Adobe-Consulting-Services.

the class PlaceholderTag method doEndTag.

/**
 * {@inheritDoc}
 */
@Override
public int doEndTag() throws JspException {
    SlingHttpServletRequest request = TagUtil.getRequest(pageContext);
    Component component = WCMUtils.getComponent(request.getResource());
    if (componentHelper.isEditMode(request)) {
        JspWriter writer = pageContext.getOut();
        String placeholder;
        String bodyContentString = bodyContent != null ? bodyContent.getString() : null;
        if (StringUtils.isNotBlank(bodyContentString)) {
            // use the body content as the default placeholder
            placeholder = Placeholder.getDefaultPlaceholder(request, component, bodyContentString, getDdClass());
        } else {
            String classicUIPlaceholder = componentHelper.generateClassicUIPlaceholder(getAllClassNames(), null);
            placeholder = Placeholder.getDefaultPlaceholder(request, component, classicUIPlaceholder, getDdClass());
        }
        try {
            writer.print(placeholder);
        } catch (IOException e) {
            throw new JspException(e);
        }
    }
    reset();
    return EVAL_PAGE;
}
Also used : JspException(javax.servlet.jsp.JspException) IOException(java.io.IOException) Component(com.day.cq.wcm.api.components.Component) JspWriter(javax.servlet.jsp.JspWriter) SlingHttpServletRequest(org.apache.sling.api.SlingHttpServletRequest)

Aggregations

JspWriter (javax.servlet.jsp.JspWriter)145 IOException (java.io.IOException)72 JspException (javax.servlet.jsp.JspException)68 HttpServletRequest (javax.servlet.http.HttpServletRequest)17 JspWriteRuntimeException (org.jaffa.presentation.portlet.widgets.taglib.exceptions.JspWriteRuntimeException)14 PageContext (javax.servlet.jsp.PageContext)13 Iterator (java.util.Iterator)9 Engine (org.apache.wiki.api.core.Engine)9 JspContext (javax.servlet.jsp.JspContext)8 JspTagException (javax.servlet.jsp.JspTagException)8 OuterFormTagMissingRuntimeException (org.jaffa.presentation.portlet.widgets.taglib.exceptions.OuterFormTagMissingRuntimeException)7 ArrayList (java.util.ArrayList)6 Properties (java.util.Properties)6 HttpSession (javax.servlet.http.HttpSession)5 BodyContent (javax.servlet.jsp.tagext.BodyContent)5 org.apache.ecs.xhtml.select (org.apache.ecs.xhtml.select)5 Page (org.apache.wiki.api.core.Page)5 HtmlCode (org.compiere.util.HtmlCode)5 MissingParametersRuntimeException (org.jaffa.presentation.portlet.widgets.taglib.exceptions.MissingParametersRuntimeException)5 IPropertyRuleIntrospector (org.jaffa.rules.IPropertyRuleIntrospector)5