/*
 * Created on May 22, 2006
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package gov.va.med.esr.ui.ee.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.commons.lang.Validate;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.util.LabelValueBean;

import gov.va.med.esr.common.model.person.Person;

import gov.va.med.esr.ui.util.ConvertUtils;
import gov.va.med.esr.ui.conversion.UIConversionService;

/**
 * @author DNS   CHENB
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class ServicePeriodDisplayAction extends EligibilityAction {
    public static final String SERVICE_PERIOD_LIST = "servicePeriodList";

	/**
	 * 
	 */
	public ServicePeriodDisplayAction() {
		super();
		// TODO Auto-generated constructor stub
	}

	/* (non-Javadoc)
	 * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
	 */
	public void afterPropertiesSet() throws Exception {
		// TODO Auto-generated method stub

	}

	public ActionForward display( ActionMapping mapping, 
			ActionForm form,
			HttpServletRequest request, 
			HttpServletResponse response )
	throws Exception 
	{
		
		ServicePeriodForm servicePeriodForm = (form instanceof ServicePeriodForm) ? (ServicePeriodForm)form : null;
		Validate.notNull(servicePeriodForm, "ServicePeriodForm bean is null.");
		Person person = getUpdatedPerson( request );
		
		UIConversionService uiConversionService = (UIConversionService)conversionService;
		uiConversionService.convert(person,servicePeriodForm);
		
        request.getSession().setAttribute(SERVICE_PERIOD_LIST, servicePeriodForm.getServicePeriodList());
        
		return mapping.findForward("success");
	}
	

}
