/**
 * Copyright (c) 2009 Penril Datability (SEA) Sdn Bhd All rights reserved.
 *
 * This software is copyrighted. Under the copyright laws, this software
 * may not be copied, in whole or in part, without prior written consent
 * of Penril Datability (SEA) Sdn Bhd or its assignees. This software is
 * provided under the terms of a license between Penril Datability (SEA)
 * Sdn Bhd and the recipient, and its use is subject to the terms of that
 * license.
 */

package my.com.kfh.controller.actions.ib104_fundtransfer.thirdparty;

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

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import my.com.kfh.controller.actions.common.ActionTag;
import my.com.kfh.enterprise.services.ib104_fundtransfer.thirdparty.IB3rdPartyMaintEditConfirmServices;
import my.com.kfh.enterprise.services.ib104_fundtransfer.thirdparty.ThirdPartyTransferTags;
import my.com.kfh.error.exception.IBGenericException;
import my.com.kfh.navigation.IBNavigation;
import my.com.kfh.web.utils.IBControllerAction;
import my.com.kfh.web.utils.IBDynaBean;
import my.com.kfh.web.utils.IBDynaBeanManager;
import my.com.kfh.web.utils.IBSessionObjects;

public class IB3rdPartyMaintEditConfirmAction extends IBControllerAction {


	public ActionForward execute (ActionMapping p_oMapping, ActionForm p_oForm, HttpServletRequest p_oRequest, HttpServletResponse p_oResponse) throws Exception
	{
		noErrorHandling (p_oRequest, p_oMapping);
		IBSessionObjects m_oSessionObjects = new IBSessionObjects(p_oRequest);

		try
		{
			checkToken (p_oRequest, p_oMapping, false);
			IBNavigation m_oNavigation = new IBNavigation(m_oSessionObjects);
			m_oNavigation.createNavigation(p_oMapping, p_oRequest);

			String m_sAction = p_oRequest.getParameter (ThirdPartyTransferTags.ACTION);
			if (ActionTag.isBack (m_sAction))
			{
				m_sAction = ActionTag.BACK;
				setForwardPage (m_sAction.toLowerCase ());
			}
			else
			{
				ActionErrors m_oActionErrors = p_oForm.validate (createNewActionMapping(p_oMapping, ThirdPartyTransferTags.VALIDATE_THIRDPARTY_MAINT_EDIT), p_oRequest);
				if(!m_oActionErrors.isEmpty ())
				{
					errorHandling(p_oRequest, p_oMapping, m_oActionErrors);
				}
				else{
					IBDynaBean m_oIBDynaBean = IBDynaBeanManager.createIBDynaBean(p_oForm, p_oMapping);
					IB3rdPartyMaintEditConfirmServices m_oServices = new IB3rdPartyMaintEditConfirmServices(m_oSessionObjects);
					m_oServices.setIBDynaBean(m_oIBDynaBean);
					m_oServices.executeServices();
				}
			}
		}
		catch (IBGenericException e)
		{
			errorHandling(p_oRequest, p_oMapping, e);
		}

		return super.execute (p_oMapping, p_oForm, p_oRequest, p_oResponse);
	}
}

