/** * Notify all interested listeners that a state was entered in the flow execution. */ public void fireStateEntered(RequestContext context, StateDefinition previousState) { for (FlowExecutionListener listener : listeners) { listener.stateEntered(context, previousState, context.getCurrentState()); } }
/** * Notify all interested listeners that a flow execution view is rendering. */ public void fireViewRendering(RequestContext context, View view) { for (FlowExecutionListener listener : listeners) { listener.viewRendering(context, view, context.getCurrentState()); } }
/** * Notify all interested listeners that a flow execution has rendered. */ public void fireViewRendered(RequestContext context, View view) { for (FlowExecutionListener listener : listeners) { listener.viewRendered(context, view, context.getCurrentState()); } }
public String resolveMethod(RequestContext context) { // implementation note: not using AnnotatedAction.METHOD_ATTRIBUTE since // that resides in the engine subsystem String method = context.getAttributes().getString("method"); if (method == null) { if (context.getCurrentState() != null) { // default to the state id method = context.getCurrentState().getId(); } else { throw new IllegalStateException("Unable to resolve action method; no 'method' context attribute set"); } } return method; } }
private Expression getModelExpression() { return (Expression) requestContext.getCurrentState().getAttributes().get("model"); }
private boolean invokeValidateMethodForCurrentState(Object model) { String methodName = "validate" + StringUtils.capitalize(requestContext.getCurrentState().getId()); // preferred Method validateMethod = ReflectionUtils.findMethod(model.getClass(), methodName, ValidationContext.class); if (validateMethod != null) { if (logger.isDebugEnabled()) { logger.debug("Invoking current state model validation method '" + methodName + "(ValidationContext)'"); } ReflectionUtils.invokeMethod(validateMethod, model, new DefaultValidationContext(requestContext, eventId, mappingResults)); return true; } // web flow 2.0.3 or < compatibility only validateMethod = ReflectionUtils.findMethod(model.getClass(), methodName, MessageContext.class); if (validateMethod != null) { ReflectionUtils.invokeMethod(validateMethod, model, requestContext.getMessageContext()); return true; } // mvc 2 compatibility only validateMethod = ReflectionUtils.findMethod(model.getClass(), methodName, Errors.class); if (validateMethod != null) { MessageContextErrors errors = new MessageContextErrors(requestContext.getMessageContext(), modelName, model, expressionParser, messageCodesResolver, mappingResults); if (logger.isDebugEnabled()) { logger.debug("Invoking current state model validation method '" + methodName + "(Errors)'"); } ReflectionUtils.invokeMethod(validateMethod, model, errors); return true; } return false; }
/** * Execute the given action. * @param action the action to execute * @param context the flow execution request context * @return result of action execution * @throws ActionExecutionException if the action threw an exception while executing, the orginal exception is * available as the cause if this exception */ public static Event execute(Action action, RequestContext context) throws ActionExecutionException { try { if (logger.isDebugEnabled()) { logger.debug("Executing " + getTargetAction(action)); } Event event = action.execute(context); if (logger.isDebugEnabled()) { logger.debug("Finished executing " + getTargetAction(action) + "; result = " + event); } return event; } catch (ActionExecutionException e) { throw e; } catch (Exception e) { // wrap the exception as an ActionExecutionException throw new ActionExecutionException(context.getActiveFlow().getId(), context.getCurrentState() != null ? context.getCurrentState().getId() : null, action, context.getAttributes(), e); } }
/** * Create a new enter state veto exception. * @param context the flow execution request context * @param vetoedState the state for which entering is vetoed * @param message a descriptive message */ public EnterStateVetoException(RequestContext context, StateDefinition vetoedState, String message) { this(context.getActiveFlow().getId(), context.getCurrentState().getId(), vetoedState.getId(), message); }
/** * Create a new enter state veto exception. * @param context the flow execution request context * @param vetoedState the state for which entering is vetoed * @param message a descriptive message * @param cause the underlying cause */ public EnterStateVetoException(RequestContext context, StateDefinition vetoedState, String message, Throwable cause) { this(context.getActiveFlow().getId(), context.getCurrentState().getId(), vetoedState.getId(), message, cause); }
private boolean invokeValidatorValidateMethodForCurrentState(Object validator) { String methodName = "validate" + StringUtils.capitalize(requestContext.getCurrentState().getId());
public void mapSubflowOutput(AttributeMap<?> output, RequestContext context) { if (outputMapper != null && output != null) { MappingResults results = outputMapper.map(output, context); if (results != null && results.hasErrorResults()) { throw new FlowOutputMappingException(context.getActiveFlow().getId(), context.getCurrentState().getId(), results); } } }
expr = (Expression) requestContext.getCurrentState().getAttributes().get("validationHints"); String stateId = requestContext.getCurrentState().getId(); try { Object hintsValue = expr.getValue(requestContext);
public MutableAttributeMap<Object> createSubflowInput(RequestContext context) { if (inputMapper != null) { LocalAttributeMap<Object> input = new LocalAttributeMap<>(); MappingResults results = inputMapper.map(context, input); if (results != null && results.hasErrorResults()) { throw new FlowInputMappingException(context.getActiveFlow().getId(), context.getCurrentState().getId(), results); } return input; } else { return new LocalAttributeMap<>(); } }
/** * Notify all interested listeners that a state was entered in the flow execution. */ public void fireStateEntered(RequestContext context, StateDefinition previousState) { for (FlowExecutionListener listener : listeners) { listener.stateEntered(context, previousState, context.getCurrentState()); } }
/** * Notify all interested listeners that a flow execution has rendered. */ public void fireViewRendered(RequestContext context, View view) { for (FlowExecutionListener listener : listeners) { listener.viewRendered(context, view, context.getCurrentState()); } }
/** * Notify all interested listeners that a state was entered in the flow execution. */ public void fireStateEntered(RequestContext context, StateDefinition previousState) { for (int i = 0; i < listeners.length; i++) { listeners[i].stateEntered(context, previousState, context.getCurrentState()); } }
/** * Determine whether or not a redirect should be used to render the application view. * @param context the context * @return true or false */ protected boolean shouldRedirect(RequestContext context) { return context.getCurrentState() instanceof ViewState && (redirect || alwaysRedirectOnPause(context)); }
private Map<String, Object> flowScopes() { if (requestContext.getCurrentState().isViewState()) { return requestContext.getConversationScope().union(requestContext.getFlowScope()) .union(requestContext.getViewScope()).union(requestContext.getFlashScope()) .union(requestContext.getRequestScope()).asMap(); } else { return requestContext.getConversationScope().union(requestContext.getFlowScope()) .union(requestContext.getFlashScope()).union(requestContext.getRequestScope()).asMap(); } }
public void mapSubflowOutput(AttributeMap output, RequestContext context) { if (outputMapper != null && output != null) { MappingResults results = outputMapper.map(output, context); if (results != null && results.hasErrorResults()) { throw new FlowOutputMappingException(context.getActiveFlow().getId(), context.getCurrentState().getId(), results); } } }
protected void setUp() throws Exception { this.jsfMock.setUp(); this.listener = new FlowActionListener(this.jsfMock.application().getActionListener()); RequestContextHolder.setRequestContext(this.context); LocalAttributeMap<Object> flash = new LocalAttributeMap<>(); EasyMock.expect(this.context.getFlashScope()).andStubReturn(flash); EasyMock.expect(this.context.getCurrentState()).andStubReturn(new MockViewState()); EasyMock.replay(this.context); }