📄 basehandlertag.java
字号:
/*
* $Id: BaseHandlerTag.java 479633 2006-11-27 14:25:35Z pbenedict $
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts.taglib.html;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.Globals;
import org.apache.struts.action.ActionMessages;
import org.apache.struts.taglib.TagUtils;
import org.apache.struts.taglib.logic.IterateTag;
import org.apache.struts.util.MessageResources;
import org.apache.struts.util.RequestUtils;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.BodyTagSupport;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
/**
* Base class for tags that render form elements capable of including
* JavaScript event handlers and/or CSS Style attributes. This class does not
* implement the doStartTag() or doEndTag() methods. Subclasses should provide
* appropriate implementations of these.
*
* @version $Rev: 479633 $ $Date: 2006-11-27 08:25:35 -0600 (Mon, 27 Nov 2006) $
*/
public abstract class BaseHandlerTag extends BodyTagSupport {
/**
* Commons Logging instance.
*/
private static Log log = LogFactory.getLog(BaseHandlerTag.class);
// ----------------------------------------------------- Instance Variables
/**
* The message resources for this package.
*/
protected static MessageResources messages =
MessageResources.getMessageResources(Constants.Package
+ ".LocalStrings");
// Navigation Management
/**
* Access key character.
*/
protected String accesskey = null;
/**
* Tab index value.
*/
protected String tabindex = null;
// Indexing ability for Iterate
/**
* Whether to created indexed names for fields
*
* @since Struts 1.1
*/
protected boolean indexed = false;
// Mouse Events
/**
* Mouse click event.
*/
private String onclick = null;
/**
* Mouse double click event.
*/
private String ondblclick = null;
/**
* Mouse over component event.
*/
private String onmouseover = null;
/**
* Mouse exit component event.
*/
private String onmouseout = null;
/**
* Mouse moved over component event.
*/
private String onmousemove = null;
/**
* Mouse pressed on component event.
*/
private String onmousedown = null;
/**
* Mouse released on component event.
*/
private String onmouseup = null;
// Keyboard Events
/**
* Key down in component event.
*/
private String onkeydown = null;
/**
* Key released in component event.
*/
private String onkeyup = null;
/**
* Key down and up together in component event.
*/
private String onkeypress = null;
// Text Events
/**
* Text selected in component event.
*/
private String onselect = null;
/**
* Content changed after component lost focus event.
*/
private String onchange = null;
// Focus Events and States
/**
* Component lost focus event.
*/
private String onblur = null;
/**
* Component has received focus event.
*/
private String onfocus = null;
/**
* Component is disabled.
*/
private boolean disabled = false;
/**
* Indicates whether 'disabled' is a valid attribute
*/
protected boolean doDisabled = true;
/**
* Component is readonly.
*/
private boolean readonly = false;
/**
* <p>Indicates whether 'readonly' is a valid attribute.</p>
*
* <p>According to the HTML 4.0 Specification <readonly> is valid
* for <input type="text">, <input type="password"> and
* <textarea"> elements. Therefore, except for those tags this value
* is set to <code>false</code>.</p>
*/
protected boolean doReadonly = false;
// CSS Style Support
/**
* Style attribute associated with component.
*/
private String style = null;
/**
* Named Style class associated with component.
*/
private String styleClass = null;
/**
* Identifier associated with component.
*/
private String styleId = null;
/**
* The request attribute key for our error messages (if any).
*/
private String errorKey = Globals.ERROR_KEY;
/**
* Style attribute associated with component when errors exist.
*/
private String errorStyle = null;
/**
* Named Style class associated with component when errors exist.
*/
private String errorStyleClass = null;
/**
* Identifier associated with component when errors exist.
*/
private String errorStyleId = null;
// Other Common Attributes
/**
* The alternate text of this element.
*/
private String alt = null;
/**
* The message resources key of the alternate text.
*/
private String altKey = null;
/**
* The name of the message resources bundle for message lookups.
*/
private String bundle = null;
/**
* The name of the session attribute key for our locale.
*/
private String locale = Globals.LOCALE_KEY;
/**
* The advisory title of this element.
*/
private String title = null;
/**
* The language code of this element.
*/
private String lang = null;
/**
* The direction for weak/neutral text of this element.
*/
private String dir = null;
/**
* The message resources key of the advisory title.
*/
private String titleKey = null;
private Class loopTagClass = null;
private Method loopTagGetStatus = null;
private Class loopTagStatusClass = null;
private Method loopTagStatusGetIndex = null;
private boolean triedJstlInit = false;
private boolean triedJstlSuccess = false;
// ------------------------------------------------------------- Properties
// Navigation Management
/**
* Sets the accessKey character.
*/
public void setAccesskey(String accessKey) {
this.accesskey = accessKey;
}
/**
* Returns the accessKey character.
*/
public String getAccesskey() {
return (this.accesskey);
}
/**
* Sets the tabIndex value.
*/
public void setTabindex(String tabIndex) {
this.tabindex = tabIndex;
}
/**
* Returns the tabIndex value.
*/
public String getTabindex() {
return (this.tabindex);
}
// Indexing ability for Iterate [since Struts 1.1]
/**
* Sets the indexed value.
*
* @since Struts 1.1
*/
public void setIndexed(boolean indexed) {
this.indexed = indexed;
}
/**
* Returns the indexed value.
*
* @since Struts 1.1
*/
public boolean getIndexed() {
return (this.indexed);
}
// Mouse Events
/**
* Sets the onClick event handler.
*/
public void setOnclick(String onClick) {
this.onclick = onClick;
}
/**
* Returns the onClick event handler.
*/
public String getOnclick() {
return onclick;
}
/**
* Sets the onDblClick event handler.
*/
public void setOndblclick(String onDblClick) {
this.ondblclick = onDblClick;
}
/**
* Returns the onDblClick event handler.
*/
public String getOndblclick() {
return ondblclick;
}
/**
* Sets the onMouseDown event handler.
*/
public void setOnmousedown(String onMouseDown) {
this.onmousedown = onMouseDown;
}
/**
* Returns the onMouseDown event handler.
*/
public String getOnmousedown() {
return onmousedown;
}
/**
* Sets the onMouseUp event handler.
*/
public void setOnmouseup(String onMouseUp) {
this.onmouseup = onMouseUp;
}
/**
* Returns the onMouseUp event handler.
*/
public String getOnmouseup() {
return onmouseup;
}
/**
* Sets the onMouseMove event handler.
*/
public void setOnmousemove(String onMouseMove) {
this.onmousemove = onMouseMove;
}
/**
* Returns the onMouseMove event handler.
*/
public String getOnmousemove() {
return onmousemove;
}
/**
* Sets the onMouseOver event handler.
*/
public void setOnmouseover(String onMouseOver) {
this.onmouseover = onMouseOver;
}
/**
* Returns the onMouseOver event handler.
*/
public String getOnmouseover() {
return onmouseover;
}
/**
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -