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;
}
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;
}
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);
}
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;
}
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);
}
}
Aggregations