use of javax.servlet.jsp.tagext.JspFragment in project HongsCORE by ihongs.
the class NuidTag method doTag.
@Override
public void doTag() throws JspException {
JspWriter out = getJspContext().getOut();
String uid;
if (this.sid != null) {
uid = Core.newIdentity(this.sid);
} else {
uid = Core.newIdentity();
}
try {
out.print(uid);
JspFragment f = getJspBody();
if (f != null)
f.invoke(out);
} catch (java.io.IOException ex) {
throw new JspException("Error in NuidTag", ex);
}
}
use of javax.servlet.jsp.tagext.JspFragment in project freemarker by apache.
the class SimpleTagDirectiveModel method execute.
public void execute(Environment env, Map args, TemplateModel[] outArgs, final TemplateDirectiveBody body) throws TemplateException, IOException {
try {
SimpleTag tag = (SimpleTag) getTagInstance();
final FreeMarkerPageContext pageContext = PageContextFactory.getCurrentPageContext();
pageContext.pushWriter(new JspWriterAdapter(env.getOut()));
try {
tag.setJspContext(pageContext);
JspTag parentTag = (JspTag) pageContext.peekTopTag(JspTag.class);
if (parentTag != null) {
tag.setParent(parentTag);
}
setupTag(tag, args, pageContext.getObjectWrapper());
if (body != null) {
tag.setJspBody(new JspFragment() {
@Override
public JspContext getJspContext() {
return pageContext;
}
@Override
public void invoke(Writer out) throws JspException, IOException {
try {
body.render(out == null ? pageContext.getOut() : out);
} catch (TemplateException e) {
throw new TemplateExceptionWrapperJspException(e);
}
}
});
pageContext.pushTopTag(tag);
try {
tag.doTag();
} finally {
pageContext.popTopTag();
}
} else {
tag.doTag();
}
} finally {
pageContext.popWriter();
}
} catch (TemplateException e) {
throw e;
} catch (Exception e) {
throw toTemplateModelExceptionOrRethrow(e);
}
}
use of javax.servlet.jsp.tagext.JspFragment in project freemarker by apache.
the class TestSimpleTag method doTag.
@Override
public void doTag() throws JspException, IOException {
JspContext ctx = getJspContext();
JspWriter w = ctx.getOut();
w.println("enter TestSimpleTag " + name);
JspFragment f = getJspBody();
for (int i = 0; i < bodyLoopCount; ++i) {
w.println("invoking body i=" + i);
f.invoke(w);
}
w.println("exit TestSimpleTag " + name);
}
use of javax.servlet.jsp.tagext.JspFragment in project jodd by oblac.
the class IteratorTag method iterateArray.
/**
* Iterates arrays.
*/
protected void iterateArray(final Object[] array, final int from, final int count, final PageContext pageContext) throws JspException {
JspFragment body = getJspBody();
int len = array.length;
int to = calculateTo(from, count, len);
int last = to - 1;
for (int i = from; i < to; i++) {
Object item = array[i];
if (status != null) {
iteratorStatus.next(i == last);
}
TagUtil.setScopeAttribute(var, item, scope, pageContext);
TagUtil.invokeBody(body);
}
}
use of javax.servlet.jsp.tagext.JspFragment in project OpenClinica by OpenClinica.
the class PrintTableTag method doTag.
/**
* This JSP Tag API method creates a instance of PrintHorizontalFormBuilder,
* then generates that class's XHTML output into the web page. The tag shows
* all sections of a CRF.
*
* @throws JspException
* @throws IOException
*/
@Override
public void doTag() throws JspException, IOException {
JspContext context = getJspContext();
JspWriter tagWriter = context.getOut();
// This request attribute is generated by the PrintCRf or PrintDataEntry
// servlets
List<DisplaySectionBean> listOfDisplayBeans = (ArrayList) context.findAttribute("listOfDisplaySectionBeans");
StudyBean studyBean = (StudyBean) context.findAttribute("study");
// EventCRFBean
EventCRFBean eventCRFBean = (EventCRFBean) context.findAttribute("EventCRFBean");
String isInternetExplorer = (String) context.findAttribute("isInternetExplorer");
if (listOfDisplayBeans != null) {
PrintHorizontalFormBuilder printFormBuilder = new PrintHorizontalFormBuilder();
// Provide the form-building code with the list of display section
// beans
printFormBuilder.setDisplaySectionBeans(listOfDisplayBeans);
// The body content of the tag contains 'true' or 'false', depending
// on whether the
// printed CRF involves data entry (and possible saved data) or not.
JspFragment fragment = this.getJspBody();
Writer stringWriter = new StringWriter();
fragment.invoke(stringWriter);
if ("true".equalsIgnoreCase(stringWriter.toString())) {
printFormBuilder.setInvolvesDataEntry(true);
}
printFormBuilder.setEventCRFbean(eventCRFBean);
if ("true".equalsIgnoreCase(isInternetExplorer)) {
printFormBuilder.setInternetExplorer(true);
}
if (studyBean != null) {
printFormBuilder.setStudyBean(studyBean);
}
if ("true".equalsIgnoreCase(stringWriter.toString())) {
tagWriter.println(printFormBuilder.createMarkup());
} else
tagWriter.println(printFormBuilder.createMarkupNoDE());
} else {
tagWriter.println("The application could not generate the markup for the printable form.<br />" + "This error may have been caused by the altering of the web page's URL; the URL needs " + "an 'id' or an 'ecId' value in its query string at the URL end.");
}
}
Aggregations