📄 showmessages.java
字号:
/* * Copyright (C) butor.com. All rights reserved. * * This software is published under the terms of the GNU Library General * Public License (GNU LGPL), a copy of which has been included with this * distribution in the LICENSE.txt file. */package org.butor.web.taglib.utils;import java.util.Collection;import java.util.Iterator;import javax.servlet.jsp.JspException;import javax.servlet.jsp.tagext.TagSupport;import org.apache.struts.util.ResponseUtils;import org.butor.helper.IMessage;import org.butor.web.context.IWebContext;import org.butor.web.context.WebContextService;/** * @author sawanai * * show messages */public class ShowMessages extends TagSupport { protected String type = null; public String getType() { return type; } public void setType(String type) { this.type = type; } /** * @see javax.servlet.jsp.tagext.Tag#doStartTag() */ public int doStartTag() throws JspException { IWebContext ctxt = WebContextService.getContext(); if (ctxt == null) { return SKIP_BODY; } Collection messages = ctxt.getMessages(); if (messages == null) { return SKIP_BODY; } int severity = -1; if (this.type != null) { if (this.type.equalsIgnoreCase("error")) { severity = IMessage.SEVERITY_ERROR; } else if (this.type.equalsIgnoreCase("info")) { severity = IMessage.SEVERITY_INFO; } else if (this.type.equalsIgnoreCase("warning")) { severity = IMessage.SEVERITY_WARN; } } Iterator it = messages.iterator(); IMessage msg = null; while(it.hasNext()) { msg = (IMessage)it.next(); if (severity == -1 || msg.getSeverity() == severity) { showMessage(msg); } } return SKIP_BODY; } protected void showMessage(IMessage message) throws JspException { ResponseUtils.write(pageContext, "<li>"); ResponseUtils.write(pageContext, message.getText()); ResponseUtils.write(pageContext, "</li>"); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -