📄 rolebuttontag.java
字号:
/**
* 类的说明
* @author 宋文凯
* @since 2005-10-31
*/
package com.oppo.elms.pub.taglib;
import java.util.Hashtable;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspException;
import org.apache.struts.taglib.html.BaseHandlerTag;
import org.apache.struts.util.ResponseUtils;
import com.oppo.elms.pub.AdmAcessCtl;
//import com.nbw.doc.wd.dao.WdflDao;
/**
* Renders an HTML BUTTON tag within the Struts framework.
*
* @author Don Clasen
* @version $Revision$ $Date$
*/
@SuppressWarnings("serial")
public class RoleButtonTag extends BaseHandlerTag {
// ----------------------------------------------------- Instance Variables
/**
* The property name of the generated button.
*/
protected String property = null;
/**
* The body content of this tag (if any).
*/
protected String text = null;
/**
* The value of the button label.
*/
protected String value = null;
protected String buttontype = null;
// ------------------------------------------------------------- Properties
/**
* Return the property name.
*/
public String getProperty() {
return (property);
}
/**
* Set the property name.
*
* @param property The property name
*/
public void setProperty(String property) {
this.property = property;
}
/**
* Return the label value.
*/
public String getValue() {
return (value);
}
/**
* Set the label value.
* @param value The label value
*/
public void setValue(String value) {
this.value = value;
}
/**
* @return 返回 auth。
*/
public String getButtontype() {
return buttontype;
}
/**
* @param auth 要设置的 auth。
*/
public void setButtontype(String buttontype) {
this.buttontype = buttontype;
}
// --------------------------------------------------------- Public Methods
/**
* Process the start of this tag.
* @exception JspException if a JSP exception has occurred
*/
@SuppressWarnings("deprecation")
public int doStartTag() throws JspException {
// Do nothing until doEndTag() is called
this.text = null;
return (EVAL_BODY_TAG);
}
/**
* Save the associated label from the body content (if any).
* @exception JspException if a JSP exception has occurred
*/
public int doAfterBody() throws JspException {
if (bodyContent != null) {
String value = bodyContent.getString().trim();
if (value.length() > 0)
text = value;
}
return (SKIP_BODY);
}
/**
* Process the end of this tag.
* <p>
* Support for indexed property since Struts 1.1
* @exception JspException if a JSP exception has occurred
*/
@SuppressWarnings("deprecation")
public int doEndTag() throws JspException {
// Acquire the label value we will be generating
String label = value;
if ((label == null) && (text != null))
label = text;
if ((label == null) || (label.trim().length() < 1))
label = "Click";
// Generate an HTML element
StringBuffer results = new StringBuffer();
results.append("<input type=\"button\"");
if (property != null) {
results.append(" name=\"");
results.append(property);
// * @since Struts 1.1
if (indexed)
prepareIndex(results, null);
results.append("\"");
}
if (accesskey != null) {
results.append(" accesskey=\"");
results.append(accesskey);
results.append("\"");
}
if (tabindex != null) {
results.append(" tabindex=\"");
results.append(tabindex);
results.append("\"");
}
if (buttontype != null) {
HttpSession session = pageContext.getSession();
@SuppressWarnings("unused")
Hashtable verifyPara = (Hashtable) session.getAttribute("hashSysPara");
int row = 0;
@SuppressWarnings("unused")
ServletRequest hreq = pageContext.getRequest();
if (session.getAttribute("toNodename") == null)
row = 0;
else {
String nodename = (String) session.getAttribute("toNodename");
String userid = (String) ((Hashtable) pageContext.getSession().getAttribute("hashSysPara")).get("userid");
AdmAcessCtl ctl = new AdmAcessCtl();
row = ctl.getRoleButton(userid, buttontype, nodename);
}
//row = 1;//tomcat
if (row <= 0){
results.append(" style=\"");
results.append("display: none");
results.append("\"");
}
}
results.append(" value=\"");
results.append(label);
results.append("\"");
results.append(prepareEventHandlers());
results.append(prepareStyles());
results.append(getElementClose());
// Render this element to our writer
ResponseUtils.write(pageContext, results.toString());
// Evaluate the remainder of this page
return (EVAL_PAGE);
}
/**
* Release any acquired resources.
*/
public void release() {
super.release();
property = null;
text = null;
value = null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -