use of org.apache.wiki.api.core.Session in project jspwiki by apache.
the class MessagesTag method doWikiStartTag.
@Override
public final int doWikiStartTag() throws IOException {
final Session session = m_wikiContext.getWikiSession();
if (CLEAR.equals(m_action)) {
if (m_topic == null) {
session.clearMessages();
} else {
session.clearMessages(m_topic);
}
} else {
final String[] messages = (m_topic == null) ? session.getMessages() : session.getMessages(m_topic);
if (messages.length > 0) {
final StringBuilder sb = new StringBuilder();
if (messages.length == 1) {
sb.append("<div class=\"").append(m_div).append("\">").append(m_prefix).append(TextUtil.replaceEntities(messages[0])).append("</div>");
} else {
sb.append("<div class=\"").append(m_div).append("\">").append(m_prefix);
sb.append("<ul>");
for (final String message : messages) {
sb.append("<li>").append(TextUtil.replaceEntities(message)).append("</li>");
}
sb.append("</ul></div>");
}
pageContext.getOut().println(sb.toString());
}
}
return SKIP_BODY;
}
Aggregations