selecteditemsrangevalidatortag.java

来自「一个ssh结构组成 的BS开发」· Java 代码 · 共 68 行

JAVA
68
字号

import javax.faces.validator.Validator;
import javax.faces.webapp.ValidatorTag;
import javax.servlet.jsp.JspException;

import cn.hxex.library.view.util.FacesUtils;

public class SelectedItemsRangeValidatorTag extends ValidatorTag
{
	// the validator id registered in JSF
	private static String VALIDATOR_ID = "cn.hxex.library.view.validator.SelectedItemsRange";

	// the minimum number of items to be selected
	private String minNum;

	// the maximum number of items to be selected
	private String maxNum;

	/**
	 * Default constructor.
	 */
	public SelectedItemsRangeValidatorTag()
	{
		this.setValidatorId(VALIDATOR_ID);
	}

	public void setMinNum(String newMinNum)
	{
		this.minNum = newMinNum;
	}

	public void setMaxNum(String newMaxNum)
	{
		this.maxNum = newMaxNum;
	}

	/**
	 * Create the validator associated with the tag.
	 * 
	 * @return the validator associated with the tag
	 */
	public Validator createValidator() throws JspException
	{
		SelectedItemsRangeValidator validator = (SelectedItemsRangeValidator) super
				.createValidator();

		Integer minValue = FacesUtils.evalInt(this.minNum);
		if (minValue != null)
		{
			validator.setMinNum(minValue.intValue());
		}

		Integer maxValue = FacesUtils.evalInt(this.maxNum);
		if (maxValue != null)
		{
			validator.setMaxNum(maxValue.intValue());
		}

		return validator;
	}

	public void release()
	{
		this.minNum = null;
		this.maxNum = null;
	}
}

⌨️ 快捷键说明

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