📄 checkboxtag.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 javax.servlet.jsp.JspException;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 CheckboxTag extends org.apache.struts.taglib.html.CheckboxTag { /** * 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 result = RequestUtils.lookup(pageContext, name, property, null); String propValue = null; if (result == null) { propValue = ""; } else if (result instanceof String) { propValue = (String) result; } else { propValue = result.toString(); } // if the property value is equal to the checkbox value // then it is on. if (propValue.equalsIgnoreCase(value)) { // Add the checked image TagLibHelper.renderText(pageContext, "<img src=\"/_images/check_on.gif\">", false); // Add an hidden field for this property TagLibHelper.renderHiddenField(pageContext, property, propValue); } else { // Add the checked image TagLibHelper.renderText(pageContext, "<img src=\"/_images/check_off.gif\">", false); } } this.text = null; return EVAL_BODY_BUFFERED; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -