⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 selecttag.java

📁 一个实用工具类
💻 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.html;import java.lang.reflect.InvocationTargetException;import javax.servlet.jsp.JspException;import org.apache.commons.beanutils.BeanUtils;import org.apache.struts.util.RequestUtils;import org.apache.struts.util.ResponseUtils;import org.butor.web.action.IButorActionForm;/** * @author nacroaz * * To change this generated comment edit the template variable "typecomment": * Window>Preferences>Java>Templates. */public class SelectTag extends org.apache.struts.taglib.html.SelectTag {	protected boolean f_isEnable = true;	protected String saveOnDisable = "1";			/**     * Render the beginning of this form.     * Indexed property since 1.1     *     * @exception JspException if a JSP exception has occurred     */    public int doStartTag() throws JspException {	   	// Find and check the form bean	      	Object o = RequestUtils.lookup(pageContext, name, null);    	        if (! (o instanceof IButorActionForm)) {			ResponseUtils.write(pageContext, "The form bean must be an instance of ButorActionForm !!!");  			return SKIP_BODY;        }                IButorActionForm form = (IButorActionForm) o;                // If property is enable, use super class definition                if ((f_isEnable = form.getEnabled(property))) {        	         	return super.doStartTag();        } else {        	// the property is disable, we must calculate the match values         	// we will actually be using	        if (value != null) {	            match = new String[1];	            match[0] = value;	        } else {	            Object bean = pageContext.findAttribute(name);	            if (bean == null) {	                JspException e = new JspException	                    (messages.getMessage("getter.bean", name));	                RequestUtils.saveException(pageContext, e);	                throw e;	            }	            try {	                match = BeanUtils.getArrayProperty(bean, property);	                if (match == null) {	                    match = new String[0];                    }	            } catch (IllegalAccessException e) {	                RequestUtils.saveException(pageContext, e);	                throw new JspException	                    (messages.getMessage("getter.access", property, name));	            } catch (InvocationTargetException e) {	                Throwable t = e.getTargetException();	                RequestUtils.saveException(pageContext, t);	                throw new JspException	                    (messages.getMessage("getter.result",	                                         property, t.toString()));	            } catch (NoSuchMethodException e) {	                RequestUtils.saveException(pageContext, e);	                throw new JspException	                    (messages.getMessage("getter.method", property, name));	            }	        }        	        }                if (saveOnDisable == null) {        	saveOnDisable = "1";	        }                // Continue processing this page        return (EVAL_BODY_BUFFERED);    }       /**     * Render the end of this form.     *     * @exception JspException if a JSP exception has occurred     */    public int doEndTag() throws JspException {        // If property is enable, use super class definition     	    	if (f_isEnable) {    		return super.doEndTag();	    	}        // Render a tag representing the end of our current form        StringBuffer results = new StringBuffer();        if (saveBody != null) {            results.append(saveBody);        }        // Print this value to our output writer        ResponseUtils.write(pageContext, results.toString());        // Continue processing this page        return (EVAL_PAGE);    }        	/**	 * Returns the saveOnDisable.	 * @return String	 */	public String getSaveOnDisable() {		return saveOnDisable;	}	/**	 * Sets the saveOnDisable.	 * @param saveOnDisable The saveOnDisable to set	 */	public void setSaveOnDisable(String saveOnDisable) {		this.saveOnDisable = saveOnDisable;	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -