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

📄 form.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:   Form.java

package org.apache.struts2.components;

import com.opensymphony.xwork2.*;
import com.opensymphony.xwork2.config.Configuration;
import com.opensymphony.xwork2.config.RuntimeConfiguration;
import com.opensymphony.xwork2.config.entities.ActionConfig;
import com.opensymphony.xwork2.config.entities.InterceptorMapping;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptorUtil;
import com.opensymphony.xwork2.util.TextUtils;
import com.opensymphony.xwork2.util.ValueStack;
import com.opensymphony.xwork2.validator.*;
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.dispatcher.Dispatcher;
import org.apache.struts2.dispatcher.mapper.ActionMapper;
import org.apache.struts2.dispatcher.mapper.ActionMapping;
import org.apache.struts2.portlet.context.PortletActionContext;
import org.apache.struts2.portlet.util.PortletUrlHelper;
import org.apache.struts2.views.util.UrlHelper;

// Referenced classes of package org.apache.struts2.components:
//			ClosingUIBean

public class Form extends ClosingUIBean
{

	private static final Log LOG = LogFactory.getLog(org/apache/struts2/components/Form);
	public static final String OPEN_TEMPLATE = "form";
	public static final String TEMPLATE = "form-close";
	private int sequence;
	protected String onsubmit;
	protected String action;
	protected String target;
	protected String enctype;
	protected String method;
	protected String namespace;
	protected String validate;
	protected String portletMode;
	protected String windowState;
	protected String acceptcharset;
	protected boolean enableDynamicMethodInvocation;
	protected Configuration configuration;
	protected ObjectFactory objectFactory;

	public Form(ValueStack stack, HttpServletRequest request, HttpServletResponse response)
	{
		super(stack, request, response);
		sequence = 0;
		enableDynamicMethodInvocation = true;
	}

	protected boolean evaluateNameValue()
	{
		return false;
	}

	public String getDefaultOpenTemplate()
	{
		return "form";
	}

	protected String getDefaultTemplate()
	{
		return "form-close";
	}

	public void setEnableDynamicMethodInvocation(String enable)
	{
		enableDynamicMethodInvocation = "true".equals(enable);
	}

	public void setConfiguration(Configuration configuration)
	{
		this.configuration = configuration;
	}

	public void setObjectFactory(ObjectFactory objectFactory)
	{
		this.objectFactory = objectFactory;
	}

	protected void evaluateExtraParams()
	{
		super.evaluateExtraParams();
		if (validate != null)
			addParameter("validate", findValue(validate, java/lang/Boolean));
		if (onsubmit != null)
			addParameter("onsubmit", findString(onsubmit));
		if (target != null)
			addParameter("target", findString(target));
		if (enctype != null)
			addParameter("enctype", findString(enctype));
		if (method != null)
			addParameter("method", findString(method));
		if (acceptcharset != null)
			addParameter("acceptcharset", findString(acceptcharset));
		if (!parameters.containsKey("tagNames"))
			addParameter("tagNames", new ArrayList());
	}

	protected void populateComponentHtmlId(Form form)
	{
		boolean isAjax = "ajax".equalsIgnoreCase(theme);
		String action = null;
		if (this.action != null)
			action = findString(this.action);
		if (id != null)
			addParameter("id", escape(id));
		if (Dispatcher.getInstance().isPortletSupportActive() && PortletActionContext.isPortletRequest())
		{
			evaluateExtraParamsPortletRequest(this.namespace, action);
		} else
		{
			String namespace = determineNamespace(this.namespace, getStack(), request);
			evaluateExtraParamsServletRequest(action, namespace, isAjax);
		}
	}

	private void evaluateExtraParamsServletRequest(String action, String namespace, boolean isAjax)
	{
		if (action == null)
		{
			ActionInvocation ai = (ActionInvocation)getStack().getContext().get("com.opensymphony.xwork2.ActionContext.actionInvocation");
			if (ai != null)
			{
				action = ai.getProxy().getActionName();
				namespace = ai.getProxy().getNamespace();
			} else
			{
				String uri = request.getRequestURI();
				action = uri.substring(uri.lastIndexOf('/'));
			}
		}
		String actionMethod = "";
		if (enableDynamicMethodInvocation && action.indexOf("!") != -1)
		{
			int endIdx = action.lastIndexOf("!");
			actionMethod = action.substring(endIdx + 1, action.length());
			action = action.substring(0, endIdx);
		}
		ActionConfig actionConfig = configuration.getRuntimeConfiguration().getActionConfig(namespace, action);
		String actionName = action;
		if (actionConfig != null)
		{
			ActionMapping mapping = new ActionMapping(action, namespace, actionMethod, parameters);
			String result = UrlHelper.buildUrl(actionMapper.getUriFromActionMapping(mapping), request, response, null);
			addParameter("action", result);
			addParameter("actionName", actionName);
			try
			{
				Class clazz = objectFactory.getClassInstance(actionConfig.getClassName());
				addParameter("actionClass", clazz);
			}
			catch (ClassNotFoundException e) { }
			addParameter("namespace", namespace);
			if (name == null)
				addParameter("name", action);
			if (id == null && action != null)
				addParameter("id", escape(action));
		} else
		if (action != null)
		{
			if (namespace != null)
				LOG.warn((new StringBuilder()).append("No configuration found for the specified action: '").append(action).append("' in namespace: '").append(namespace).append("'. Form action defaulting to 'action' attribute's literal value.").toString());
			String result = UrlHelper.buildUrl(action, request, response, null);
			addParameter("action", result);
			int slash = result.lastIndexOf('/');
			if (slash != -1)
				addParameter("namespace", result.substring(0, slash));
			else
				addParameter("namespace", "");
			if (id == null)
			{
				slash = result.lastIndexOf('/');
				int dot = result.indexOf('.', slash);
				if (dot != -1)
					id = result.substring(slash + 1, dot);
				else
					id = result.substring(slash + 1);
				addParameter("id", escape(id));
			}
		}
		evaluateClientSideJsEnablement(actionName, namespace, actionMethod);
	}

	private void evaluateClientSideJsEnablement(String actionName, String namespace, String actionMethod)
	{
label0:
		{
			Boolean validate = (Boolean)getParameters().get("validate");
			if (validate == null || !validate.booleanValue())
				break label0;
			addParameter("performValidation", Boolean.FALSE);
			RuntimeConfiguration runtimeConfiguration = configuration.getRuntimeConfiguration();
			ActionConfig actionConfig = runtimeConfiguration.getActionConfig(namespace, actionName);
			if (actionConfig == null)
				break label0;
			List interceptors = actionConfig.getInterceptors();
			Iterator i$ = interceptors.iterator();
			InterceptorMapping interceptorMapping;
			do
			{
				if (!i$.hasNext())
					break label0;
				interceptorMapping = (InterceptorMapping)i$.next();
			} while (!com/opensymphony/xwork2/validator/ValidationInterceptor.isInstance(interceptorMapping.getInterceptor()));
			ValidationInterceptor validationInterceptor = (ValidationInterceptor)interceptorMapping.getInterceptor();
			java.util.Set excludeMethods = validationInterceptor.getExcludeMethodsSet();
			java.util.Set includeMethods = validationInterceptor.getIncludeMethodsSet();
			if (MethodFilterInterceptorUtil.applyMethod(excludeMethods, includeMethods, actionMethod))
				addParameter("performValidation", Boolean.TRUE);
			return;
		}
	}

	private void evaluateExtraParamsPortletRequest(String namespace, String action)
	{
		String type = "action";
		if (TextUtils.stringSet(method) && "GET".equalsIgnoreCase(method.trim()))
			type = "render";
		if (action != null)
		{
			String result = PortletUrlHelper.buildUrl(action, namespace, null, getParameters(), type, portletMode, windowState);
			addParameter("action", result);
			int slash = result.lastIndexOf('/');
			if (slash != -1)
				addParameter("namespace", result.substring(0, slash));
			else
				addParameter("namespace", "");
			if (id == null)
			{
				slash = action.lastIndexOf('/');
				int dot = action.indexOf('.', slash);
				if (dot != -1)
					id = action.substring(slash + 1, dot);
				else
					id = action.substring(slash + 1);
				addParameter("id", escape(id));
			}
		}
	}

	public List getValidators(String name)
	{
		Class actionClass = (Class)getParameters().get("actionClass");
		if (actionClass == null)
			return Collections.EMPTY_LIST;
		List all = ActionValidatorManagerFactory.getInstance().getValidators(actionClass, (String)getParameters().get("actionName"));
		List validators = new ArrayList();
		Iterator i$ = all.iterator();
		do
		{
			if (!i$.hasNext())
				break;
			Validator validator = (Validator)i$.next();
			if (validator instanceof FieldValidator)
			{
				FieldValidator fieldValidator = (FieldValidator)validator;
				if (fieldValidator.getFieldName().equals(name))
					validators.add(fieldValidator);
			}
		} while (true);
		return validators;
	}

	protected int getSequence()
	{
		return sequence++;
	}

	public void setOnsubmit(String onsubmit)
	{
		this.onsubmit = onsubmit;
	}

	public void setAction(String action)
	{
		this.action = action;
	}

	public void setTarget(String target)
	{
		this.target = target;
	}

	public void setEnctype(String enctype)
	{
		this.enctype = enctype;
	}

	public void setMethod(String method)
	{
		this.method = method;
	}

	public void setNamespace(String namespace)
	{
		this.namespace = namespace;
	}

	public void setValidate(String validate)
	{
		this.validate = validate;
	}

	public void setPortletMode(String portletMode)
	{
		this.portletMode = portletMode;
	}

	public void setWindowState(String windowState)
	{
		this.windowState = windowState;
	}

	public void setAcceptcharset(String acceptcharset)
	{
		this.acceptcharset = acceptcharset;
	}

}

⌨️ 快捷键说明

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