Search in sources :

Example 76 with JspWriter

use of javax.servlet.jsp.JspWriter in project jspwiki by apache.

the class LinkTag method doEndTag.

@Override
public int doEndTag() {
    try {
        final Engine engine = m_wikiContext.getEngine();
        final JspWriter out = pageContext.getOut();
        final String url = figureOutURL();
        final StringBuilder sb = new StringBuilder(20);
        sb.append((m_cssClass != null) ? "class=\"" + m_cssClass + "\" " : "");
        sb.append((m_style != null) ? "style=\"" + m_style + "\" " : "");
        sb.append((m_target != null) ? "target=\"" + m_target + "\" " : "");
        sb.append((m_title != null) ? "title=\"" + m_title + "\" " : "");
        sb.append((m_rel != null) ? "rel=\"" + m_rel + "\" " : "");
        sb.append((m_accesskey != null) ? "accesskey=\"" + m_accesskey + "\" " : "");
        sb.append((m_tabindex != null) ? "tabindex=\"" + m_tabindex + "\" " : "");
        if (engine.getManager(PageManager.class).getPage(m_pageName) instanceof Attachment) {
            sb.append(engine.getManager(AttachmentManager.class).forceDownload(m_pageName) ? "download " : "");
        }
        switch(m_format) {
            case URL:
                out.print(url);
                break;
            default:
            case ANCHOR:
                out.print("<a " + sb + " href=\"" + url + "\">");
                break;
        }
        // Add any explicit body content. This is not the intended use of LinkTag, but happens to be the way it has worked previously.
        if (m_bodyContent != null) {
            final String linktext = m_bodyContent.getString().trim();
            out.write(linktext);
        }
        // Finish off by closing opened anchor
        if (m_format == ANCHOR)
            out.print("</a>");
    } catch (final Exception e) {
        // Yes, we want to catch all exceptions here, including RuntimeExceptions
        log.error("Tag failed", e);
    }
    return EVAL_PAGE;
}
Also used : Attachment(org.apache.wiki.api.core.Attachment) AttachmentManager(org.apache.wiki.attachment.AttachmentManager) JspWriter(javax.servlet.jsp.JspWriter) Engine(org.apache.wiki.api.core.Engine) ProviderException(org.apache.wiki.api.exceptions.ProviderException)

Example 77 with JspWriter

use of javax.servlet.jsp.JspWriter in project jspwiki by apache.

the class LinkToTag method doWikiStartTag.

@Override
public int doWikiStartTag() throws IOException {
    String pageName = m_pageName;
    boolean isattachment = false;
    if (m_pageName == null) {
        final Page p = m_wikiContext.getPage();
        if (p != null) {
            pageName = p.getName();
            isattachment = p instanceof Attachment;
        } else {
            return SKIP_BODY;
        }
    }
    final JspWriter out = pageContext.getOut();
    final String url;
    final String linkclass;
    String forceDownload = "";
    if (isattachment) {
        url = m_wikiContext.getURL(ContextEnum.PAGE_ATTACH.getRequestContext(), pageName, (getVersion() != null) ? "version=" + getVersion() : null);
        linkclass = "attachment";
        if (m_wikiContext.getEngine().getManager(AttachmentManager.class).forceDownload(pageName)) {
            forceDownload = "download ";
        }
    } else {
        final StringBuilder params = new StringBuilder();
        if (getVersion() != null) {
            params.append("version=").append(getVersion());
        }
        if (getTemplate() != null) {
            params.append(params.length() > 0 ? "&amp;" : "").append("skin=").append(getTemplate());
        }
        url = m_wikiContext.getURL(ContextEnum.PAGE_VIEW.getRequestContext(), pageName, params.toString());
        linkclass = "wikipage";
    }
    switch(m_format) {
        case ANCHOR:
            out.print("<a class=\"" + linkclass + "\" href=\"" + url + "\" accesskey=\"" + m_accesskey + "\" title=\"" + m_title + "\" " + forceDownload + ">");
            break;
        case URL:
            out.print(url);
            break;
    }
    return EVAL_BODY_INCLUDE;
}
Also used : Page(org.apache.wiki.api.core.Page) Attachment(org.apache.wiki.api.core.Attachment) AttachmentManager(org.apache.wiki.attachment.AttachmentManager) JspWriter(javax.servlet.jsp.JspWriter)

Example 78 with JspWriter

use of javax.servlet.jsp.JspWriter in project jspwiki by apache.

the class AttachmentsIteratorTag method doAfterBody.

/**
 *  {@inheritDoc}
 */
@Override
public final int doAfterBody() {
    if (bodyContent != null) {
        try {
            final JspWriter out = getPreviousOut();
            out.print(bodyContent.getString());
            bodyContent.clearBody();
        } catch (final IOException e) {
            log.error("Unable to get inner tag text", e);
        // FIXME: throw something?
        }
    }
    if (m_iterator != null && m_iterator.hasNext()) {
        final Attachment att = (Attachment) m_iterator.next();
        final Context context = m_wikiContext.clone();
        context.setPage(att);
        pageContext.setAttribute(Context.ATTR_CONTEXT, context, PageContext.REQUEST_SCOPE);
        pageContext.setAttribute(getId(), att);
        return EVAL_BODY_BUFFERED;
    }
    return SKIP_BODY;
}
Also used : Context(org.apache.wiki.api.core.Context) PageContext(javax.servlet.jsp.PageContext) Attachment(org.apache.wiki.api.core.Attachment) IOException(java.io.IOException) JspWriter(javax.servlet.jsp.JspWriter)

Example 79 with JspWriter

use of javax.servlet.jsp.JspWriter in project jspwiki by apache.

the class RSSImageLinkTag method doWikiStartTag.

/**
 *  {@inheritDoc}
 */
@Override
public final int doWikiStartTag() throws IOException {
    final Engine engine = m_wikiContext.getEngine();
    final JspWriter out = pageContext.getOut();
    final ResourceBundle rb = Preferences.getBundle(m_wikiContext, InternationalizationManager.CORE_BUNDLE);
    if (engine.getManager(RSSGenerator.class) != null && engine.getManager(RSSGenerator.class).isEnabled()) {
        if (RSSGenerator.MODE_FULL.equals(m_mode)) {
            final String rssURL = engine.getGlobalRSSURL();
            if (rssURL != null) {
                out.print("<a class=\"feed\" href=\"" + rssURL);
                out.print(" title='" + rb.getString("rss.title.full") + "'>");
                out.print("&nbsp;</a> ");
            }
        } else {
            final String page = m_pageName != null ? m_pageName : m_wikiContext.getPage().getName();
            final String params = "page=" + page + "&mode=" + m_mode;
            out.print("<a href='" + m_wikiContext.getURL(ContextEnum.PAGE_NONE.getRequestContext(), "rss.jsp", params));
            out.print("' class='feed'");
            out.print(" title='" + MessageFormat.format(rb.getString("rss.title"), page) + "'>");
            out.print("&nbsp;</a> ");
        }
    }
    return SKIP_BODY;
}
Also used : ResourceBundle(java.util.ResourceBundle) JspWriter(javax.servlet.jsp.JspWriter) Engine(org.apache.wiki.api.core.Engine)

Example 80 with JspWriter

use of javax.servlet.jsp.JspWriter in project head by mifos.

the class BulkEntryTag method doStartTag.

@SuppressWarnings("unchecked")
@Override
public int doStartTag() throws JspException {
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
    JspWriter out = pageContext.getOut();
    StringBuilder builder = new StringBuilder();
    CollectionSheetEntryGridDto bulkEntry = null;
    try {
        bulkEntry = (CollectionSheetEntryGridDto) SessionUtils.getAttribute(CollectionSheetEntryConstants.BULKENTRY, request);
    } catch (PageExpiredException e) {
        logger.error("Page expired getting BulkEntryBO.");
    }
    if (null != bulkEntry) {
        List<ProductDto> loanProducts = bulkEntry.getLoanProducts();
        List<ProductDto> savingsProducts = bulkEntry.getSavingProducts();
        try {
            final List<CustomValueListElementDto> custAttTypes = (List<CustomValueListElementDto>) SessionUtils.getAttribute(CollectionSheetEntryConstants.CUSTOMERATTENDANCETYPES, request);
            String method = request.getParameter(CollectionSheetEntryConstants.METHOD);
            generateTagData(bulkEntry, loanProducts, savingsProducts, custAttTypes, method, builder);
        } catch (ApplicationException ae) {
            throw new JspException(ae);
        } catch (SystemException se) {
            throw new JspException(se);
        }
    }
    try {
        out.write(builder.toString());
    } catch (IOException ioe) {
        throw new JspException(ioe);
    }
    return SKIP_BODY;
}
Also used : CustomValueListElementDto(org.mifos.application.master.business.CustomValueListElementDto) PageExpiredException(org.mifos.framework.exceptions.PageExpiredException) IOException(java.io.IOException) JspWriter(javax.servlet.jsp.JspWriter) HttpServletRequest(javax.servlet.http.HttpServletRequest) JspException(javax.servlet.jsp.JspException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) SystemException(org.mifos.framework.exceptions.SystemException) List(java.util.List) ProductDto(org.mifos.application.servicefacade.ProductDto) CollectionSheetEntryGridDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryGridDto)

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