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

📄 radiotag.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 RadioTag extends org.apache.struts.taglib.html.RadioTag {	    /**     * Generate the required input tag.     * [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 (form.getEnabled(property)) {        	return super.doStartTag();        } else {                	// the property is disable, we must render it properly         	        		        // Acquire the current value of the appropriate field    	    Object current = null;        	Object bean = pageContext.findAttribute(name);	        if (bean == null){	        	    	        throw new JspException(messages.getMessage("getter.bean", name));	        }                			        try {    	        current = BeanUtils.getProperty(bean, property);        	    if (current == null) {            	    current = "";        	    }            } catch (IllegalAccessException e) {                throw new JspException(messages.getMessage("getter.access", property, name));            } catch (InvocationTargetException e) {                Throwable t = e.getTargetException();                throw new JspException(messages.getMessage("getter.result", property, t.toString()));	        } catch (NoSuchMethodException e) {    	        throw new JspException(messages.getMessage("getter.method", property, name));	        }              		            // If current value match the tag value, then render this property as checked			if (current.equals(value)) {        	  				//  Add the checked image				TagLibHelper.renderText(pageContext, "<img src=\"/_images/radio_on.gif\">", false);	            				// Add an hidden field for this property				TagLibHelper.renderHiddenField(pageContext, property, current.toString());				} else {				//  Add the checked image				TagLibHelper.renderText(pageContext, "<img src=\"/_images/radio_off.gif\">", false);			}        }                this.text = null;        return EVAL_BODY_BUFFERED;    }    }

⌨️ 快捷键说明

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