package com.jspdev.ch17;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.*;

import javax.servlet.http.HttpServletRequest;
 
public class DepartmentForm extends ActionForm  {
 
   private Department department=new Department() ;
    
   public void setDepartment(Department department)
   {
   	   this.department=department;
   }
   public Department getDepartment()
   {
   	   return this.department;
   	}
   	public void setName(String name)
   	{
   		this.department.setName(name);
   	}
   	public String getName()
   	{
   		return this.department.getName();
   	}
    
    public void reset(ActionMapping mapping, HttpServletRequest request) {
        this.department=new Department() ;
    }
    
    public ActionErrors validate(ActionMapping mapping,
                    HttpServletRequest request)
     {
        ActionErrors errors = new ActionErrors();
        if ((department.getName() == null) || (department.getLeader()==null))
        { 
            errors.add("password", new ActionError("error.user.password"));
        }
        return errors;
     }

}