Search in sources :

Example 11 with BodyContent

use of javax.servlet.jsp.tagext.BodyContent in project tomcat by apache.

the class JspRuntimeLibrary method startBufferedBody.

public static JspWriter startBufferedBody(PageContext pageContext, BodyTag tag) throws JspException {
    BodyContent out = pageContext.pushBody();
    tag.setBodyContent(out);
    tag.doInitBody();
    return out;
}
Also used : BodyContent(javax.servlet.jsp.tagext.BodyContent)

Example 12 with BodyContent

use of javax.servlet.jsp.tagext.BodyContent in project jodd by oblac.

the class FormTag method doAfterBody.

/**
	 * Performs smart form population.
	 */
@Override
public int doAfterBody() throws JspException {
    BodyContent body = getBodyContent();
    JspWriter out = body.getEnclosingWriter();
    String bodytext = populateForm(body.getString(), new FormFieldResolver() {

        public Object value(String name) {
            return JspResolver.value(name, pageContext);
        }
    });
    try {
        out.print(bodytext);
    } catch (IOException ioex) {
        throw new JspException(ioex);
    }
    return SKIP_BODY;
}
Also used : BodyContent(javax.servlet.jsp.tagext.BodyContent) JspException(javax.servlet.jsp.JspException) IOException(java.io.IOException) JspWriter(javax.servlet.jsp.JspWriter)

Example 13 with BodyContent

use of javax.servlet.jsp.tagext.BodyContent in project OpenAM by OpenRock.

the class CCPropertySheetTag method getValueHTML.

@Override
protected String getValueHTML(Node valueNode, String labelId, boolean levelThree) throws JspException, IllegalArgumentException {
    if (valueNode == null) {
        CCDebug.trace1("Property node missing value element");
        return null;
    }
    String viewName = getAttributeValue(valueNode, "name", "");
    String tagclassName = getAttributeValue(valueNode, "tagclass", "com.sun.web.ui.taglib.html.CCStaticTextFieldTag");
    View child = null;
    if (!tagclassName.equals("com.sun.web.ui.taglib.spacer.CCSpacerTag") && !tagclassName.equals("org.forgerock.openam.console.ui.taglib.spacer.CCSpacerTag")) {
        child = containerView.getChild(viewName);
    }
    CCTagBase tag = getCCTag(tagclassName);
    tag.setName(viewName);
    if (labelId != null) {
        tag.setElementId(labelId);
    }
    if (tagclassName.equals("com.sun.web.ui.taglib.html.CCCheckBoxTag")) {
        CCCheckBoxTag cb = (CCCheckBoxTag) tag;
        cb.setStyleLevel(levelThree ? "3" : "2");
        cb.setElementId(getNextLabelId());
    } else if (tagclassName.equals("com.sun.web.ui.taglib.html.CCRadioButtonTag")) {
        CCRadioButtonTag rb = (CCRadioButtonTag) tag;
        rb.setStyleLevel(levelThree ? "3" : "2");
        rb.setElementId(getNextLabelId());
    }
    if (valueNode.hasChildNodes()) {
        NodeList childNodeList = valueNode.getChildNodes();
        BodyContent bodyContent = null;
        if (tag instanceof BodyTag) {
            bodyContent = new CCBodyContentImpl(new CCJspWriterImpl(null, 100, false));
        }
        OptionList options = null;
        if (child != null && (child instanceof SelectableGroup)) {
            options = new OptionList();
        }
        for (int i = 0; i < childNodeList.getLength(); i++) {
            parseValueChildNode(childNodeList.item(i), tag, bodyContent, options);
        }
        if (bodyContent != null) {
            ((BodyTag) tag).setBodyContent(bodyContent);
        }
        if (options != null && options.size() > 0) {
            ((SelectableGroup) child).setOptions(options);
        }
    }
    if (tag.getBundleID() == null) {
        tag.setBundleID(getBundleID());
    }
    tag.setTabIndex(getTabIndex());
    String html = null;
    if (fireBeginDisplayEvent(containerView, tag)) {
        html = tag.getHTMLString(getParent(), pageContext, child);
    }
    return fireEndDisplayEvent(containerView, tag, html);
}
Also used : CCBodyContentImpl(com.sun.web.ui.common.CCBodyContentImpl) BodyTag(javax.servlet.jsp.tagext.BodyTag) NodeList(org.w3c.dom.NodeList) CCJspWriterImpl(com.sun.web.ui.common.CCJspWriterImpl) CCCheckBoxTag(com.sun.web.ui.taglib.html.CCCheckBoxTag) View(com.iplanet.jato.view.View) BodyContent(javax.servlet.jsp.tagext.BodyContent) SelectableGroup(com.iplanet.jato.view.html.SelectableGroup) CCRadioButtonTag(com.sun.web.ui.taglib.html.CCRadioButtonTag) OptionList(com.iplanet.jato.view.html.OptionList) CCTagBase(com.sun.web.ui.taglib.common.CCTagBase)

Example 14 with BodyContent

use of javax.servlet.jsp.tagext.BodyContent in project OpenAM by OpenRock.

the class DSAMEHrefTag method doEndTag.

/**
     * does end tag
     *
     * @return SKIP_PAGE if tag is not going to be displayed
     */
public int doEndTag() throws JspException {
    try {
        if (abortedException != null) {
            throw abortedException;
        }
        if (displayed) {
            BodyContent bodyContent = getBodyContent();
            if (bodyContent != null) {
                // Assume that "true" is default for trim
                if (getTrim() == null || isTrue(getTrim())) {
                    buffer.append(bodyContent.getString().trim());
                } else {
                    buffer.append(bodyContent.getString());
                }
            }
            buffer.append("</a>");
            writeOutput(fireEndDisplayEvent(buffer.toString()));
        }
    } catch (CompleteRequestException e) {
        // CompleteRequestException tunneling workaround:
        // Workaround to allow developers to stop the request
        // from a display event by throwing a CompleteRequestException.
        // The problem is that some containers catch this exception in
        // their JSP rendering subsystem, and so we need to tunnel it
        // through for the developer.
        // Mark the JSP rendering as cancelled.  The calling
        // ViewBean.foward() or ViewBean.include() methods
        // should pick this up and then throw a complete request
        // exception that was properly thrown here.
        getRequestContext().getRequest().setAttribute(ViewBeanBase.DISPLAY_EVENT_COMPLETED_REQUEST_ATTRIBUTE_NAME, e);
        return SKIP_PAGE;
    }
    return EVAL_PAGE;
}
Also used : BodyContent(javax.servlet.jsp.tagext.BodyContent) CompleteRequestException(com.iplanet.jato.CompleteRequestException)

Example 15 with BodyContent

use of javax.servlet.jsp.tagext.BodyContent in project sling by apache.

the class CallTag method doEndTag.

@Override
public int doEndTag() throws JspException {
    final SlingBindings bindings = (SlingBindings) pageContext.getRequest().getAttribute(SlingBindings.class.getName());
    final SlingScriptHelper scriptHelper = bindings.getSling();
    final ServletResolver servletResolver = scriptHelper.getService(ServletResolver.class);
    final RequestProgressTracker tracker = TagUtil.getRequest(pageContext).getRequestProgressTracker();
    String servletName = null;
    final Servlet servlet;
    if (!ignoreComponentHierarchy) {
        final Resource resource = bindings.getResource();
        servlet = servletResolver.resolveServlet(resource, this.script);
        if (servlet != null) {
            servletName = RequestUtil.getServletName(servlet);
            tracker.log("Including script {0} for path={1}, type={2}: {3}", script, resource.getPath(), resource.getResourceType(), servletName);
        }
    } else {
        final ResourceResolver resolver = bindings.getRequest().getResourceResolver();
        final String scriptPath;
        if (!script.startsWith("/")) {
            // resolve relative script
            String parentPath = ResourceUtil.getParent(scriptHelper.getScript().getScriptResource().getPath());
            // check if parent resides on search path
            for (String sp : resolver.getSearchPath()) {
                if (parentPath.startsWith(sp)) {
                    parentPath = parentPath.substring(sp.length());
                    break;
                }
            }
            scriptPath = parentPath + "/" + script;
        } else {
            scriptPath = this.script;
        }
        servlet = servletResolver.resolveServlet(resolver, scriptPath);
        if (servlet != null) {
            servletName = RequestUtil.getServletName(servlet);
            tracker.log("Including script {0} (ignoring component hierarchy): {1}", script, servletName);
        }
    }
    if (servlet == null) {
        throw new JspException("Could not find script " + script);
    }
    try {
        if (flush && !(pageContext.getOut() instanceof BodyContent)) {
            // might throw an IOException of course
            pageContext.getOut().flush();
        }
        // wrap the response to get the correct output order
        SlingHttpServletResponse response = new JspSlingHttpServletResponseWrapper(pageContext);
        tracker.startTimer(servletName);
        servlet.service(pageContext.getRequest(), response);
        tracker.logTimer(servletName);
        return EVAL_PAGE;
    } catch (Exception e) {
        throw new JspException("Error while executing script " + script, e);
    }
}
Also used : SlingHttpServletResponse(org.apache.sling.api.SlingHttpServletResponse) JspSlingHttpServletResponseWrapper(org.apache.sling.scripting.jsp.util.JspSlingHttpServletResponseWrapper) SlingBindings(org.apache.sling.api.scripting.SlingBindings) SlingScriptHelper(org.apache.sling.api.scripting.SlingScriptHelper) Resource(org.apache.sling.api.resource.Resource) JspException(javax.servlet.jsp.JspException) BodyContent(javax.servlet.jsp.tagext.BodyContent) JspException(javax.servlet.jsp.JspException) ServletResolver(org.apache.sling.api.servlets.ServletResolver) ResourceResolver(org.apache.sling.api.resource.ResourceResolver) Servlet(javax.servlet.Servlet) RequestProgressTracker(org.apache.sling.api.request.RequestProgressTracker)

Aggregations

BodyContent (javax.servlet.jsp.tagext.BodyContent)18 IOException (java.io.IOException)4 RequestDispatcher (javax.servlet.RequestDispatcher)3 JspException (javax.servlet.jsp.JspException)3 Servlet (javax.servlet.Servlet)2 PageContextImpl (lucee.runtime.PageContextImpl)2 CacheHandler (lucee.runtime.cache.tag.CacheHandler)2 CacheHandlerPro (lucee.runtime.cache.tag.CacheHandlerPro)2 CacheItem (lucee.runtime.cache.tag.CacheItem)2 SlingHttpServletResponse (org.apache.sling.api.SlingHttpServletResponse)2 Resource (org.apache.sling.api.resource.Resource)2 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)2 SlingBindings (org.apache.sling.api.scripting.SlingBindings)2 SlingScriptHelper (org.apache.sling.api.scripting.SlingScriptHelper)2 ServletResolver (org.apache.sling.api.servlets.ServletResolver)2 JspSlingHttpServletResponseWrapper (org.apache.sling.scripting.jsp.util.JspSlingHttpServletResponseWrapper)2 CompleteRequestException (com.iplanet.jato.CompleteRequestException)1 View (com.iplanet.jato.view.View)1 OptionList (com.iplanet.jato.view.html.OptionList)1 SelectableGroup (com.iplanet.jato.view.html.SelectableGroup)1