View Javadoc
1 package com.mlw.fps.controller; 2 3 import java.io.IOException; 4 5 import javax.servlet.ServletException; 6 import javax.servlet.http.HttpServletRequest; 7 import javax.servlet.http.HttpServletResponse; 8 import javax.servlet.http.HttpSession; 9 10 import org.apache.commons.logging.Log; 11 import org.apache.commons.logging.LogFactory; 12 import org.apache.struts.action.ActionForm; 13 import org.apache.struts.action.ActionForward; 14 import org.apache.struts.action.ActionMapping; 15 16 import com.mlw.fps.model.business.bean.SystemProperties; 17 import com.mlw.fps.view.manager.ViewManager; 18 19 /*** All actions should extend this abstract class. The 20 * purpose of this base class is to serve the viewManager 21 * to the actions. 22 */ 23 24 public abstract class BaseAction extends org.apache.struts.action.Action 25 { 26 protected final static Log log = LogFactory.getLog(BaseAction.class); 27 28 /*** Checks if the ConsoleManager is initialized, then passes controll to the 29 * implementing class by calling <code>executeAction</code> 30 * response (or forward to another web component that will create it). 31 * Return an <code>ActionForward</code> instance describing where and how 32 * control should be forwarded, or <code>null</code> if the response has 33 * already been completed. 34 * 35 * @param form ActionForm 36 * @param mapping The ActionMapping used to select this instance 37 * @param request The HTTP request we are processing 38 * @param response The HTTP response we are creating 39 * @exception IOException if an input/output error occurs 40 * @exception ServletException if a servlet exception occurs 41 * @return Forward 42 */ 43 public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) 44 throws IOException, ServletException 45 { 46 if ( log.isDebugEnabled() ) log.debug("Executing: " + mapping.getName() ); 47 48 ViewManager manager = getManager(request); 49 if( doInitialization() && !manager.getConsoleManager().initialized() ) 50 { 51 SystemProperties.setProperty("homeDirectory", request.getRealPath(".") ); 52 return mapping.findForward("console"); 53 } 54 55 ActionForward performResult = executeAction(mapping, form, manager); 56 return performResult; 57 } 58 59 /*** Process the specified HTTP request, and create the corresponding HTTP 60 * @param mapping The ActionMapping used to select this instance 61 * @param form ActionForm 62 * @param manager ViewManager assigned to this session. 63 * @exception IOException if an input/output error occurs 64 * @exception ServletException if a servlet exception occurs 65 * @return Forward 66 */ 67 public abstract ActionForward executeAction(ActionMapping mapping, ActionForm form, ViewManager manager) 68 throws IOException, ServletException; 69 70 /*** Can override this if the configuration check should not be performed. 71 * @return boolean, check. 72 */ 73 public boolean doInitialization() 74 { 75 return true; 76 } 77 78 /*** Retrieves the ViewManager 79 * @param request Request to get ViewManager 80 * @return ViewManager 81 */ 82 private ViewManager getManager(HttpServletRequest request) 83 { 84 HttpSession session = request.getSession(); 85 ViewManager manager = (ViewManager)session.getAttribute("viewManager"); 86 if (manager == null) 87 { 88 manager = new ViewManager(); 89 session.setAttribute("viewManager",manager); 90 } 91 return manager; 92 } 93 }

This page was automatically generated by Maven