1 7 package com.inversoft.verge.mvc.controller.actionflow; 8 9 10 import javax.servlet.http.HttpServletRequest ; 11 import javax.servlet.http.HttpServletResponse ; 12 13 import com.inversoft.verge.mvc.MVCConstants; 14 import com.inversoft.verge.mvc.MVCException; 15 import com.inversoft.verge.mvc.MVCRequest; 16 import com.inversoft.verge.mvc.controller.ControllerHandler; 17 import com.inversoft.verge.mvc.controller.Result; 18 import com.inversoft.verge.mvc.controller.actionflow.config.ActionFlowConfigStruct; 19 import com.inversoft.verge.mvc.controller.actionflow.config.Node; 20 import com.inversoft.verge.mvc.controller.actionflow.config.RenderableNode; 21 22 23 37 public class ActionFlowControllerHandler implements ControllerHandler { 38 39 45 public void preExecute(MVCRequest mvcRequest) throws MVCException { 46 47 HttpServletRequest request = mvcRequest.getRequest(); 48 ActionFlowMetaData md = ActionFlowURLTools.decodeURL( 49 mvcRequest.getControllerInfo().getURLValues()); 50 if (md.getAction() == null) { 51 ActionFlowURLTools.locateAction(request, md); 52 } 53 54 mvcRequest.setModelEnabled(md.isModelEnabled()); 56 mvcRequest.setValidationEnabled(md.isValidationEnabled()); 57 58 HttpServletResponse response = mvcRequest.getResponse(); 60 ActionFlowAction afa = new ActionFlowAction(md.getAction(), request, 61 response, null, mvcRequest.getRequestContext()); 62 mvcRequest.setAction(afa); 63 64 ActionFlowConfigStruct config = new ActionFlowConfigStruct(null, md); 66 67 if (md.getForm() != null && md.getNamespace() != null) { 68 config.baseFormConfig = config.actionFlowMetaData.findFormConfig(request); 69 mvcRequest.addValidatorHandlerToCall(MVCConstants.ACTIONFLOW_NAME); 70 } 71 72 mvcRequest.setConfiguration(config); 73 } 74 75 78 public Result execute(MVCRequest mvcRequest) throws MVCException { 79 HttpServletRequest request = mvcRequest.getRequest(); 80 HttpServletResponse response = mvcRequest.getResponse(); 81 ActionFlowConfigStruct config = 82 (ActionFlowConfigStruct) mvcRequest.getConfiguration(); 83 84 String namespace = config.actionFlowMetaData.getNamespace(); 86 Node node = null; 87 88 if (config.failedValidatorConfig != null) { 90 node = ActionFlowExecutor.execute(request, response, namespace, 91 config.actionFlowMetaData.getEntry(), 92 config.failedValidatorConfig.getFailureDefinition(), null); 93 } else { 94 node = ActionFlowExecutor.execute(request, response, namespace, 95 config.actionFlowMetaData.getEntry(), 96 (ActionFlowAction) mvcRequest.getAction()); 97 } 98 99 Result result = null; 100 if (node != null && node instanceof RenderableNode) { 101 result = (RenderableNode) node; 102 } 103 104 return result; 105 } 106 } | Popular Tags |