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;
}
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 ? "&" : "").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;
}
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;
}
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(" </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(" </a> ");
}
}
return SKIP_BODY;
}
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;
}
Aggregations