checkboxinterceptor.java

来自「struts 2 核心包 的源码 有错误是难免的」· Java 代码 · 共 62 行

JAVA
62
字号
// 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:   CheckboxInterceptor.java

package org.apache.struts2.interceptor;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;
import java.util.*;

public class CheckboxInterceptor
	implements Interceptor
{

	private static final long serialVersionUID = 0xf7dafd791c82b76fL;
	private String uncheckedValue;

	public CheckboxInterceptor()
	{
		uncheckedValue = Boolean.FALSE.toString();
	}

	public void destroy()
	{
	}

	public void init()
	{
	}

	public String intercept(ActionInvocation ai)
		throws Exception
	{
		Map parameters = ai.getInvocationContext().getParameters();
		Map newParams = new HashMap();
		Set keys = parameters.keySet();
		Iterator iterator = keys.iterator();
		do
		{
			if (!iterator.hasNext())
				break;
			String key = (String)iterator.next();
			if (key.startsWith("__checkbox_"))
			{
				String name = key.substring("__checkbox_".length());
				iterator.remove();
				if (!parameters.containsKey(name))
					newParams.put(name, uncheckedValue);
			}
		} while (true);
		parameters.putAll(newParams);
		return ai.invoke();
	}

	public void setUncheckedValue(String uncheckedValue)
	{
		this.uncheckedValue = uncheckedValue;
	}
}

⌨️ 快捷键说明

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