Search in sources :

Example 56 with JspWriter

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

the class StylesTag method serializeElements.

/**
 * Write out the HTML tags for each element.
 *
 * @param styles The styles.
 * @throws IOException If there was an error writing the styles.
 */
private void serializeElements(final Collection styles) throws IOException {
    final JspWriter out = this.pageContext.getOut();
    final Iterator elements = styles.iterator();
    while (elements.hasNext()) {
        final Element element = (Element) elements.next();
        element.serialize(out);
    }
}
Also used : Element(com.revolsys.ui.html.view.Element) Iterator(java.util.Iterator) JspWriter(javax.servlet.jsp.JspWriter)

Example 57 with JspWriter

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

the class ScriptsTag method doStartTag.

/**
 * Process the start tag.
 *
 * @return SKIP_BODY
 * @throws JspException If there was an exception processing the tag.
 */
@Override
public int doStartTag() throws JspException {
    try {
        final WebUiContext context = WebUiContext.get();
        if (context != null) {
            final Page page = context.getPage();
            if (page != null) {
                final JspWriter out = this.pageContext.getOut();
                String contextPath = context.getContextPath();
                if (contextPath.equals("/")) {
                    contextPath = "";
                }
                final Iterator scripts = page.getScripts().iterator();
                while (scripts.hasNext()) {
                    final String script = (String) scripts.next();
                    out.print("<script type=\"text/javascript\" src=\"");
                    out.print(contextPath);
                    out.print(script);
                    out.println("\">\n</script>");
                }
            }
        }
        final SiteNodeController controller = (SiteNodeController) this.pageContext.findAttribute("rsWebController");
        if (controller instanceof PageController) {
            final PageController page = (PageController) controller;
            writeScripts(page.getScripts());
        }
    } catch (final Throwable t) {
        log.error(t.getMessage(), t);
    }
    return SKIP_BODY;
}
Also used : SiteNodeController(com.revolsys.ui.web.config.SiteNodeController) PageController(com.revolsys.ui.web.config.PageController) Iterator(java.util.Iterator) Page(com.revolsys.ui.web.config.Page) WebUiContext(com.revolsys.ui.web.config.WebUiContext) JspWriter(javax.servlet.jsp.JspWriter)

Example 58 with JspWriter

use of javax.servlet.jsp.JspWriter in project i2p.i2p-bote by i2p.

the class PrintExceptionTag method doTag.

@Override
public void doTag() {
    PageContext pageContext = (PageContext) getJspContext();
    JspWriter out = pageContext.getOut();
    if (exception != null) {
        try {
            out.println("<div class=\"stackTrace\">");
            exception.printStackTrace(new PrintWriter(out));
            out.println("</div>");
        } catch (IOException e) {
            log.error("Can't write output to HTML page", e);
        }
    }
}
Also used : PageContext(javax.servlet.jsp.PageContext) IOException(java.io.IOException) JspWriter(javax.servlet.jsp.JspWriter) PrintWriter(java.io.PrintWriter)

Example 59 with JspWriter

use of javax.servlet.jsp.JspWriter in project i2p.i2p-bote by i2p.

the class SendEmailTag method doEndTag.

@Override
public int doEndTag() throws JspException {
    JspWriter out = pageContext.getOut();
    Email email = new Email(includeSentTime);
    String statusMessage;
    if (recipients.isEmpty())
        statusMessage = _t("Error: Please add at least one recipient.");
    else
        try {
            // set addresses
            InternetAddress ia = new InternetAddress(senderAddress);
            email.setFrom(ia);
            // We must continue to set "Sender:" even with only one mailbox
            // in "From:", which is against RFC 2822 but required for older
            // Bote versions to see a sender (and validate the signature).
            email.setSender(ia);
            email.setSubject(subject, "UTF-8");
            for (Recipient recipient : recipients) email.addRecipient(recipient.type, recipient.address);
            // TODO: Comment out until we determine if this is necessary
            // email.fixAddresses();
            // set the text and add attachments
            email.setContent(message, attachments);
            // send the email
            I2PBote.getInstance().sendEmail(email);
            // delete attachment temp files
            for (Attachment attachment : attachments) {
                if (!attachment.clean())
                    log.error("Can't clean up attachment: <" + attachment + ">");
            }
            statusMessage = _t("The email has been queued for sending.");
        } catch (PasswordException e) {
            throw new JspException(e);
        } catch (NoIdentityForSenderException e) {
            statusMessage = _t("Error sending email: {0}", _t("No identity matches the sender/from field: {0}", e.getSender()));
            log.error("Error sending email", e);
        } catch (AddressException e) {
            statusMessage = _t("Error sending email: {0}", _t("Address doesn't contain an Email Destination or an external address: {0}", e.getRef()));
            log.error("Error sending email", e);
        } catch (Exception e) {
            statusMessage = _t("Error sending email: {0}", e.getLocalizedMessage());
            log.error("Error sending email", e);
        }
    try {
        out.println(statusMessage);
    } catch (IOException e) {
        log.error("Can't write output to HTML page", e);
    }
    return EVAL_PAGE;
}
Also used : PasswordException(i2p.bote.fileencryption.PasswordException) JspException(javax.servlet.jsp.JspException) InternetAddress(javax.mail.internet.InternetAddress) Email(i2p.bote.email.Email) NoIdentityForSenderException(i2p.bote.email.NoIdentityForSenderException) AddressException(javax.mail.internet.AddressException) Attachment(i2p.bote.email.Attachment) FileAttachment(i2p.bote.email.FileAttachment) IOException(java.io.IOException) JspWriter(javax.servlet.jsp.JspWriter) AddressException(javax.mail.internet.AddressException) PasswordException(i2p.bote.fileencryption.PasswordException) JspException(javax.servlet.jsp.JspException) IOException(java.io.IOException) NoIdentityForSenderException(i2p.bote.email.NoIdentityForSenderException)

Example 60 with JspWriter

use of javax.servlet.jsp.JspWriter in project i2p.i2p-bote by i2p.

the class FormatPlainTextTag method doTag.

@Override
public void doTag() {
    PageContext pageContext = (PageContext) getJspContext();
    JspWriter out = pageContext.getOut();
    try {
        // Handle both CRLF and LF
        text = text.replaceAll(CRLF + CRLF, "<p/>");
        text = text.replaceAll(CRLF, "<br/>");
        text = text.replaceAll(LF + LF, "<p/>");
        text = text.replaceAll(LF, "<br/>");
        // Insert a br tag between two p tags. Do it twice to handle >2 p tags in a row.
        text = text.replaceAll("<p/><p/>", "<p/><br/><p/>");
        text = text.replaceAll("<p/><p/>", "<p/><br/><p/>");
        out.println(text);
    } catch (IOException e) {
        log.error("Can't write output to HTML page", e);
    }
}
Also used : PageContext(javax.servlet.jsp.PageContext) IOException(java.io.IOException) JspWriter(javax.servlet.jsp.JspWriter)

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