public void OnAfterStep(String wizardName, String stepName, WizardStepPage step) { }
public void IncludeActions(Controller controller) { IRailsEngineContext context = controller.Context; IWizardController wizardController = controller as IWizardController; if (wizardController == null) { throw new RailsException("The controller {0} must implement the interface " + "IWizardController to be used as a wizard", controller.Name); } steps = wizardController.GetSteps(controller.Context); if (steps == null || steps.Length == 0) { throw new RailsException("The controller {0} returned no WizardStepPage", controller.Name); } IList stepList = new ArrayList(); controller.DynamicActions["start"] = this; urlInfo = controller.Context.UrlInfo; rawAction = urlInfo.Action; requestedAction = ObtainRequestedAction(rawAction, out innerAction); foreach (WizardStepPage step in steps) { String actionName = step.ActionName; if (String.Compare(requestedAction, actionName, true) == 0) { currentStepInstance = step; if (innerAction != null) { // If there's an inner action, we invoke it as a step too controller.DynamicActions[rawAction] = new DelegateDynamicAction(new ActionDelegate(OnStepActionRequested)); } } controller.DynamicActions[actionName] = new DelegateDynamicAction(new ActionDelegate(OnStepActionRequested)); stepList.Add(actionName); step.Initialize(controller); } context.UnderlyingContext.Items["wizard.step.list"] = stepList; if (currentStepInstance != null && !HasRequiredSessionData(controller)) { StartWizard(controller, false); } SetUpWizardHelper(controller); SetUpWizardHelper(currentStepInstance); }
public bool OnBeforeStep(String wizardName, String stepName, WizardStepPage step) { return true; }
/// <summary> /// Implementation of IDynamicActionProvider. /// <para> /// Grab all steps related to the wizard /// and register them as dynamic actions. /// </para> /// </summary> /// <param name="controller">Wizard controller (must implement <see cref="IWizardController"/></param> public void IncludeActions(Controller controller) { IRailsEngineContext context = controller.Context; // Primordial assert IWizardController wizardController = controller as IWizardController; if (wizardController == null) { throw new RailsException("The controller {0} must implement the interface " + "IWizardController to be used as a wizard", controller.Name); } // Grab all Wizard Steps steps = wizardController.GetSteps(controller.Context); if (steps == null || steps.Length == 0) { throw new RailsException("The controller {0} returned no WizardStepPage", controller.Name); } IList stepList = new ArrayList(); // Include the "start" dynamic action, which resets the wizard state controller.DynamicActions["start"] = this; // Find out the action request (and possible inner action) // Each action will be a step name, or maybe the step name + action (ie Page1-Save) urlInfo = controller.Context.UrlInfo; rawAction = urlInfo.Action; requestedAction = ObtainRequestedAction(rawAction, out innerAction); // If no inner action was found, fallback to 'RenderWizardView' if (innerAction == null || innerAction == String.Empty) { innerAction = "RenderWizardView"; } IControllerLifecycleExecutorFactory execFactory = (IControllerLifecycleExecutorFactory) context.GetService(typeof(IControllerLifecycleExecutorFactory)); // Initialize all steps and while we are at it, // discover the current step foreach(WizardStepPage step in steps) { String actionName = step.ActionName; if (String.Compare(requestedAction, actionName, true) == 0) { currentStepInstance = step; if (innerAction != null) { // If there's an inner action, we invoke it as a step too controller.DynamicActions[rawAction] = new DelegateDynamicAction(new ActionDelegate(OnStepActionRequested)); } context.CurrentController = step; } controller.DynamicActions[actionName] = new DelegateDynamicAction(new ActionDelegate(OnStepActionRequested)); stepList.Add(actionName); IControllerLifecycleExecutor stepExec = execFactory.CreateExecutor(step, context); stepExec.InitializeController(controller.AreaName, controller.Name, innerAction); step.Initialize(controller); if (currentStepInstance == step) { currentStepExecutor = stepExec; if (!stepExec.SelectAction(innerAction, controller.Name)) { stepExec.PerformErrorHandling(); return; } if (!stepExec.RunStartRequestFilters()) { context.UnderlyingContext.Response.End(); } } } context.Items["wizard.step.list"] = stepList; SetUpWizardHelper(controller); SetUpWizardHelper(currentStepInstance); }