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

📄 uibean.java

📁 struts 2 核心包 的源码 有错误是难免的
💻 JAVA
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   UIBean.java

package org.apache.struts2.components;

import com.opensymphony.xwork2.config.ConfigurationException;
import com.opensymphony.xwork2.util.ValueStack;
import java.io.Writer;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.components.template.Template;
import org.apache.struts2.components.template.TemplateEngine;
import org.apache.struts2.components.template.TemplateEngineManager;
import org.apache.struts2.components.template.TemplateRenderingContext;
import org.apache.struts2.views.util.ContextUtil;

// Referenced classes of package org.apache.struts2.components:
//			Component, Form

public abstract class UIBean extends Component
{

	private static final Log LOG = LogFactory.getLog(org/apache/struts2/components/UIBean);
	protected HttpServletRequest request;
	protected HttpServletResponse response;
	protected String templateSuffix;
	protected String template;
	protected String templateDir;
	protected String theme;
	protected String key;
	protected String cssClass;
	protected String cssStyle;
	protected String disabled;
	protected String label;
	protected String labelPosition;
	protected String requiredposition;
	protected String name;
	protected String required;
	protected String tabindex;
	protected String value;
	protected String title;
	protected String onclick;
	protected String ondblclick;
	protected String onmousedown;
	protected String onmouseup;
	protected String onmouseover;
	protected String onmousemove;
	protected String onmouseout;
	protected String onfocus;
	protected String onblur;
	protected String onkeypress;
	protected String onkeydown;
	protected String onkeyup;
	protected String onselect;
	protected String onchange;
	protected String accesskey;
	protected String tooltip;
	protected String tooltipConfig;
	protected String defaultTemplateDir;
	protected String defaultUITheme;
	protected TemplateEngineManager templateEngineManager;

	public UIBean(ValueStack stack, HttpServletRequest request, HttpServletResponse response)
	{
		super(stack);
		this.request = request;
		this.response = response;
		templateSuffix = ContextUtil.getTemplateSuffix(stack.getContext());
	}

	public void setDefaultTemplateDir(String dir)
	{
		defaultTemplateDir = dir;
	}

	public void setDefaultUITheme(String theme)
	{
		defaultUITheme = theme;
	}

	public void setTemplateEngineManager(TemplateEngineManager mgr)
	{
		templateEngineManager = mgr;
	}

	public boolean end(Writer writer, String body)
	{
		evaluateParams();
		super.end(writer, body, false);
		mergeTemplate(writer, buildTemplateName(template, getDefaultTemplate()));
		popComponentStack();
		break MISSING_BLOCK_LABEL_64;
		Exception e;
		e;
		LOG.error("error when rendering", e);
		popComponentStack();
		break MISSING_BLOCK_LABEL_64;
		Exception exception;
		exception;
		popComponentStack();
		throw exception;
		return false;
	}

	protected abstract String getDefaultTemplate();

	protected Template buildTemplateName(String myTemplate, String myDefaultTemplate)
	{
		String template = myDefaultTemplate;
		if (myTemplate != null)
			template = findString(myTemplate);
		String templateDir = getTemplateDir();
		String theme = getTheme();
		return new Template(templateDir, theme, template);
	}

	protected void mergeTemplate(Writer writer, Template template)
		throws Exception
	{
		TemplateEngine engine = templateEngineManager.getTemplateEngine(template, templateSuffix);
		if (engine == null)
			throw new ConfigurationException((new StringBuilder()).append("Unable to find a TemplateEngine for template ").append(template).toString());
		if (LOG.isDebugEnabled())
			LOG.debug((new StringBuilder()).append("Rendering template ").append(template).toString());
		TemplateRenderingContext context = new TemplateRenderingContext(template, writer, getStack(), getParameters(), this);
		engine.renderTemplate(context);
	}

	public String getTemplateDir()
	{
		String templateDir = null;
		if (this.templateDir != null)
			templateDir = findString(this.templateDir);
		if (templateDir == null || templateDir.equals(""))
			templateDir = (String)stack.findValue("#attr.templateDir");
		if (templateDir == null || templateDir.equals(""))
			templateDir = defaultTemplateDir;
		if (templateDir == null || templateDir.equals(""))
			templateDir = "template";
		return templateDir;
	}

	public String getTheme()
	{
		String theme = null;
		if (this.theme != null)
			theme = findString(this.theme);
		if (theme == null || theme.equals(""))
		{
			Form form = (Form)findAncestor(org/apache/struts2/components/Form);
			if (form != null)
				theme = form.getTheme();
		}
		if (theme == null || theme.equals(""))
			theme = (String)stack.findValue("#attr.theme");
		if (theme == null || theme.equals(""))
			theme = defaultUITheme;
		return theme;
	}

	public void evaluateParams()
	{
		addParameter("templateDir", getTemplateDir());
		addParameter("theme", getTheme());
		String name = null;
		if (key != null)
		{
			if (this.name == null)
				this.name = key;
			if (label == null)
				label = (new StringBuilder()).append("%{getText('").append(key).append("')}").toString();
		}
		if (this.name != null)
		{
			name = findString(this.name);
			addParameter("name", name);
		}
		if (label != null)
			addParameter("label", findString(label));
		if (labelPosition != null)
			addParameter("labelposition", findString(labelPosition));
		if (requiredposition != null)
			addParameter("requiredposition", findString(requiredposition));
		if (required != null)
			addParameter("required", findValue(required, java/lang/Boolean));
		if (disabled != null)
			addParameter("disabled", findValue(disabled, java/lang/Boolean));
		if (tabindex != null)
			addParameter("tabindex", findString(tabindex));
		if (onclick != null)
			addParameter("onclick", findString(onclick));
		if (ondblclick != null)
			addParameter("ondblclick", findString(ondblclick));
		if (onmousedown != null)
			addParameter("onmousedown", findString(onmousedown));
		if (onmouseup != null)
			addParameter("onmouseup", findString(onmouseup));
		if (onmouseover != null)
			addParameter("onmouseover", findString(onmouseover));
		if (onmousemove != null)
			addParameter("onmousemove", findString(onmousemove));
		if (onmouseout != null)
			addParameter("onmouseout", findString(onmouseout));
		if (onfocus != null)
			addParameter("onfocus", findString(onfocus));
		if (onblur != null)
			addParameter("onblur", findString(onblur));
		if (onkeypress != null)
			addParameter("onkeypress", findString(onkeypress));
		if (onkeydown != null)
			addParameter("onkeydown", findString(onkeydown));
		if (onkeyup != null)
			addParameter("onkeyup", findString(onkeyup));
		if (onselect != null)
			addParameter("onselect", findString(onselect));
		if (onchange != null)
			addParameter("onchange", findString(onchange));
		if (accesskey != null)
			addParameter("accesskey", findString(accesskey));
		if (cssClass != null)
			addParameter("cssClass", findString(cssClass));
		if (cssStyle != null)
			addParameter("cssStyle", findString(cssStyle));
		if (title != null)
			addParameter("title", findString(title));
		if (parameters.containsKey("value"))
			parameters.put("nameValue", parameters.get("value"));
		else
		if (evaluateNameValue())
		{
			Class valueClazz = getValueClassType();
			if (valueClazz != null)
			{
				if (value != null)
					addParameter("nameValue", findValue(value, valueClazz));
				else
				if (name != null)
				{
					String expr = name;
					if (altSyntax())
						expr = (new StringBuilder()).append("%{").append(expr).append("}").toString();
					addParameter("nameValue", findValue(expr, valueClazz));
				}
			} else
			if (value != null)
				addParameter("nameValue", findValue(value));
			else
			if (name != null)
				addParameter("nameValue", findValue(name));
		}
		Form form = (Form)findAncestor(org/apache/struts2/components/Form);
		populateComponentHtmlId(form);
		if (form != null)
		{
			addParameter("form", form.getParameters());
			if (name != null)
			{
				List tags = (List)form.getParameters().get("tagNames");
				tags.add(name);
			}
		}
		if (tooltipConfig != null)
			addParameter("tooltipConfig", findValue(tooltipConfig));
		if (tooltip != null)
		{
			addParameter("tooltip", findString(tooltip));
			Map tooltipConfigMap = getTooltipConfig(this);
			if (form != null)
			{
				form.addParameter("hasTooltip", Boolean.TRUE);
				Map overallTooltipConfigMap = getTooltipConfig(form);
				overallTooltipConfigMap.putAll(tooltipConfigMap);
				java.util.Map.Entry entry;
				for (Iterator i = overallTooltipConfigMap.entrySet().iterator(); i.hasNext(); addParameter((String)entry.getKey(), entry.getValue()))
					entry = (java.util.Map.Entry)i.next();

			} else
			{
				LOG.warn("No ancestor Form found, javascript based tooltip will not work, however standard HTML tooltip using alt and title attribute will still work ");
			}
		}
		evaluateExtraParams();
	}

	protected String escape(String name)
	{
		if (name != null)
			return name.replaceAll("[\\.\\[\\]]", "_");
		else
			return "";
	}

	protected void evaluateExtraParams()
	{
	}

	protected boolean evaluateNameValue()
	{
		return true;
	}

	protected Class getValueClassType()
	{
		return java/lang/String;
	}

	public void addFormParameter(String key, Object value)
	{
		Form form = (Form)findAncestor(org/apache/struts2/components/Form);
		if (form != null)
			form.addParameter(key, value);
	}

	protected void enableAncestorFormCustomOnsubmit()
	{
		Form form = (Form)findAncestor(org/apache/struts2/components/Form);
		if (form != null)
			form.addParameter("customOnsubmitEnabled", Boolean.TRUE);
		else
			LOG.warn("Cannot find an Ancestor form, custom onsubmit is NOT enabled");
	}

	protected Map getTooltipConfig(UIBean component)
	{
		Object tooltipConfigObj = component.getParameters().get("tooltipConfig");
		Map tooltipConfig = new LinkedHashMap();
		if (tooltipConfigObj instanceof Map)
			tooltipConfig = new LinkedHashMap((Map)tooltipConfigObj);
		else
		if (tooltipConfigObj instanceof String)
		{
			String tooltipConfigStr = (String)tooltipConfigObj;
			String tooltipConfigArray[] = tooltipConfigStr.split("\\|");
			for (int a = 0; a < tooltipConfigArray.length; a++)
			{
				String configEntry[] = tooltipConfigArray[a].trim().split("=");
				String key = configEntry[0].trim();
				String value = null;
				if (configEntry.length > 1)
				{
					value = configEntry[1].trim();
					tooltipConfig.put(key, value.toString());
				} else
				{
					LOG.warn((new StringBuilder()).append("component ").append(component).append(" tooltip config param ").append(key).append(" has no value defined, skipped").toString());
				}
			}

		}
		return tooltipConfig;
	}

	protected void populateComponentHtmlId(Form form)
	{
		String tryId;
		if (id != null)
		{
			if (altSyntax())
				tryId = findString(id);
			else
				tryId = id;
		} else
		if (form != null)
			tryId = (new StringBuilder()).append(form.getParameters().get("id")).append("_").append(escape(name == null ? null : findString(name))).toString();
		else
			tryId = escape(name == null ? null : findString(name));
		addParameter("id", tryId);
		addParameter("escapedId", escape(tryId));
	}

	public void setTemplateDir(String templateDir)
	{
		this.templateDir = templateDir;
	}

	public void setTheme(String theme)
	{
		this.theme = theme;
	}

	public String getTemplate()
	{
		return template;
	}

	public void setTemplate(String template)
	{
		this.template = template;
	}

	public void setCssClass(String cssClass)
	{
		this.cssClass = cssClass;
	}

	public void setCssStyle(String cssStyle)
	{
		this.cssStyle = cssStyle;
	}

	public void setTitle(String title)
	{
		this.title = title;
	}

	public void setDisabled(String disabled)
	{
		this.disabled = disabled;
	}

	public void setLabel(String label)
	{
		this.label = label;
	}

	public void setLabelposition(String labelPosition)
	{
		this.labelPosition = labelPosition;
	}

	public void setRequiredposition(String requiredposition)
	{
		this.requiredposition = requiredposition;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public void setRequired(String required)
	{
		this.required = required;
	}

	public void setTabindex(String tabindex)
	{
		this.tabindex = tabindex;
	}

	public void setValue(String value)
	{
		this.value = value;
	}

	public void setOnclick(String onclick)
	{
		this.onclick = onclick;
	}

	public void setOndblclick(String ondblclick)
	{
		this.ondblclick = ondblclick;
	}

	public void setOnmousedown(String onmousedown)
	{
		this.onmousedown = onmousedown;
	}

	public void setOnmouseup(String onmouseup)
	{
		this.onmouseup = onmouseup;
	}

	public void setOnmouseover(String onmouseover)
	{
		this.onmouseover = onmouseover;
	}

	public void setOnmousemove(String onmousemove)
	{
		this.onmousemove = onmousemove;
	}

	public void setOnmouseout(String onmouseout)
	{
		this.onmouseout = onmouseout;
	}

	public void setOnfocus(String onfocus)
	{
		this.onfocus = onfocus;
	}

	public void setOnblur(String onblur)
	{
		this.onblur = onblur;
	}

	public void setOnkeypress(String onkeypress)
	{
		this.onkeypress = onkeypress;
	}

	public void setOnkeydown(String onkeydown)
	{
		this.onkeydown = onkeydown;
	}

	public void setOnkeyup(String onkeyup)
	{
		this.onkeyup = onkeyup;
	}

	public void setOnselect(String onselect)
	{
		this.onselect = onselect;
	}

	public void setOnchange(String onchange)
	{
		this.onchange = onchange;
	}

	public void setAccesskey(String accesskey)
	{
		this.accesskey = accesskey;
	}

	public void setTooltip(String tooltip)
	{
		this.tooltip = tooltip;
	}

	public void setTooltipConfig(String tooltipConfig)
	{
		this.tooltipConfig = tooltipConfig;
	}

	public void setKey(String key)
	{
		this.key = key;
	}

}

⌨️ 快捷键说明

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