use of javax.servlet.jsp.JspWriter in project com.revolsys.open by revolsys.
the class ScriptsTag method writeScripts.
/**
* Write out the HTML tags for each script.
*
* @param scripts The scripts.
* @throws IOException If there was an error writing the scripts.
*/
private void writeScripts(final Collection scripts) throws IOException {
final JspWriter out = this.pageContext.getOut();
for (final Iterator scriptIter = scripts.iterator(); scriptIter.hasNext(); ) {
final Script script = (Script) scriptIter.next();
final String content = script.getContent();
if (content != null) {
out.print("<script type=\"");
out.print(script.getType());
out.println("\">");
out.println(content);
out.println("</script>");
} else {
out.print("<script src=\"");
out.print(script.getFile());
out.print("\" type=\"");
out.print(script.getType());
out.println("\">\n</script>");
}
}
}
use of javax.servlet.jsp.JspWriter in project com.revolsys.open by revolsys.
the class AbstractElementTag method doTag.
/**
* Process the tag.
*
* @throws JspException If there was an exception processing the tag.
* @throws IOException If an i/o error occurs.
*/
@Override
public void doTag() throws JspException, IOException {
try {
final JspContext jspContext = getJspContext();
final JspWriter out = jspContext.getOut();
final ExpressionEvaluator expressionEvaluator = jspContext.getExpressionEvaluator();
final Collection elements = (Collection) expressionEvaluator.evaluate(this.elementExpression, Collection.class, jspContext.getVariableResolver(), null);
if (elements != null) {
serializeElements(out, elements);
}
} catch (final Throwable t) {
log.error(t.getMessage(), t);
throw new JspTagException(t.getMessage(), t);
}
}
use of javax.servlet.jsp.JspWriter in project com.revolsys.open by revolsys.
the class AbstractMapElementTag method doTag.
/**
* Process the tag.
*
* @throws JspException If there was an exception processing the tag.
* @throws IOException If an i/o error occurs.
*/
@Override
public void doTag() throws JspException, IOException {
try {
final JspContext jspContext = getJspContext();
final JspWriter out = jspContext.getOut();
final ExpressionEvaluator expressionEvaluator = jspContext.getExpressionEvaluator();
final Object t = expressionEvaluator.evaluate(this.mapExpression, Object.class, jspContext.getVariableResolver(), null);
if (t instanceof Map) {
final Map map = (Map) t;
if (map != null) {
final Object object = map.get(this.key);
serializeObject(out, object);
}
} else {
log.debug(t);
}
} catch (final Throwable t) {
log.error(t.getMessage(), t);
throw new JspTagException(t.getMessage(), t);
}
}
use of javax.servlet.jsp.JspWriter in project jforum2 by rafaelsteil.
the class TrailTag method doWikiStartTag.
/**
* @see com.ecyrd.jspwiki.tags.WikiTagBase#doWikiStartTag()
*/
public final int doWikiStartTag() throws IOException {
HttpSession session = pageContext.getSession();
FixedQueue trail = (FixedQueue) session.getAttribute(BREADCRUMBTRAIL_KEY);
String page = m_wikiContext.getPage().getName();
if (trail == null) {
trail = new FixedQueue(maxPages);
}
if (m_wikiContext.getRequestContext().equals(WikiContext.VIEW)) {
if (trail.isEmpty()) {
trail.push(page);
} else {
// Don't add the page to the queue if the page was just refreshed
if (!((String) trail.getLast()).equals(page)) {
if (trailType.equalsIgnoreCase("visit")) {
if (!trail.contains(page)) {
trail.push(page);
}
} else {
trail.push(page);
}
}
}
}
// our trail
session.setAttribute(BREADCRUMBTRAIL_KEY, trail);
JspWriter out = pageContext.getOut();
int queueSize = trail.size();
String linkClass = "wikipage";
WikiEngine engine = m_wikiContext.getEngine();
int i = 0;
for (Iterator iter = trail.iterator(); iter.hasNext(); i++) {
String currentPage = (String) iter.next();
StringBuffer sb = new StringBuffer(128).append("<a class='").append(linkClass).append("' href='").append(engine.getViewURL(currentPage)).append("'>");
if (currentPage == page) {
sb.append("<b>").append(currentPage).append("</b>");
} else {
sb.append(currentPage);
}
sb.append("</a>");
out.print(sb.toString());
if (i + 1 < queueSize) {
out.print(trailSeparator);
}
}
return SKIP_BODY;
}
use of javax.servlet.jsp.JspWriter in project acs-aem-commons by Adobe-Consulting-Services.
the class PlaceholderTag method doEndTag.
/**
* {@inheritDoc}
*/
@Override
public int doEndTag() throws JspException {
SlingHttpServletRequest request = TagUtil.getRequest(pageContext);
Component component = WCMUtils.getComponent(request.getResource());
if (componentHelper.isEditMode(request)) {
JspWriter writer = pageContext.getOut();
String placeholder;
String bodyContentString = bodyContent != null ? bodyContent.getString() : null;
if (StringUtils.isNotBlank(bodyContentString)) {
// use the body content as the default placeholder
placeholder = Placeholder.getDefaultPlaceholder(request, component, bodyContentString, getDdClass());
} else {
String classicUIPlaceholder = componentHelper.generateClassicUIPlaceholder(getAllClassNames(), null);
placeholder = Placeholder.getDefaultPlaceholder(request, component, classicUIPlaceholder, getDdClass());
}
try {
writer.print(placeholder);
} catch (IOException e) {
throw new JspException(e);
}
}
reset();
return EVAL_PAGE;
}
Aggregations