//===========================================================================
// package
//===========================================================================
package jp.gr.java_conf.bugslife.form;

//===========================================================================
// import
//===========================================================================
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.commons.logging.*;

import org.apache.struts.validator.ValidatorForm;
import java.io.UnsupportedEncodingException;

import jp.gr.java_conf.bugslife.util.Varidater;
/**
 *<PRE>
 * LogonFormクラス
 *
 *</PRE>
 * @author 鰐川　正寛
 * @version 1.0.0
 */
public class LogonForm extends ActionForm {
//===========================================================================
// attributes
//===========================================================================
	/**
	 * アクション
	 */
	private String m_action;
	/**
	 * user id
	 */
	private String m_userName;
	/**
	 * password
	 */
	private String m_password;
	/**
	 * bno
	 */
	private int m_bno;
	/**
	 * Log
	 */
	private Log log = LogFactory.getLog(this.getClass().getName());
//===========================================================================
// methods
//===========================================================================
	/**
	 * アクションの取得
	 * 
	 * @return アクション
	 */
	public String getAction()
	{
		return m_action;
	}
	/**
	 * アクションのセット
	 * 
	 * @param action アクション
	 */
	public void setAction(String action)
	{
		m_action = action;
	}
	/**
	 * user nameのセット
	 * 
	 * @param userId user name
	 */
	public void setUserName(String userName) {
		m_userName = userName;
	}
	/**
	 * user idの取得
	 * 
	 * @return user id
	 */
	public String getUserName() {
		return m_userName;
	}
	/**
	 * passwordのセット
	 * 
	 * @param passwd password
	 */
	public void setPassword(String password) {
		m_password = password;
	}
	/**
	 * passwordの取得
	 * 
	 * @return password
	 */
	public String getPassword() {
		return m_password;
	}
	/**
	 * bnoの取得
	 * 
	 * @return bno
	 */
	public int getBno()
	{
		return m_bno;
	}
	/**
	 * bnoのセット
	 * 
	 * @param bno bno
	 */
	public void setBno(int bno)
	{
		m_bno = bno;
	}
//===========================================================================
// Public Methods
//===========================================================================
	/**
	* Reset all properties to their default values.
	*
	* @param mapping The mapping used to select this instance
	* @param request The servlet request we are processing
	*/
	public void reset(ActionMapping mapping, HttpServletRequest request) {
	
		//debug
		log.debug("reset");
		//encodeing セット
		try {
			request.setCharacterEncoding("SJIS");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		
		m_action = null;
		m_userName = null;
		m_password = null;
		m_bno = 0;
	
	}
	/**
	* Validate the properties that have been set from this HTTP request,
	* and return an <code>ActionErrors</code> object that encapsulates any
	* validation errors that have been found.  If no errors are found, return
	* <code>null</code> or an <code>ActionErrors</code> object with no
	* recorded error messages.
	*
	* @param mapping The mapping used to select this instance
	* @param request The servlet request we are processing
	*/
	public ActionErrors validate(ActionMapping mapping,
								 HttpServletRequest request) {
		ActionErrors errors = new ActionErrors();
		
		if (m_bno != 0) {
			Varidater.checkRequired(m_action, "action", errors);
			Varidater.checkRequired(m_userName, "userName", errors);
			Varidater.checkRequired(m_password, "password", errors);
		}
		return errors;
	}
}