private ViewStateModel parseViewState(Element element) { ViewStateModel state = new ViewStateModel(element.getAttribute("id")); state.setParent(element.getAttribute("parent")); state.setView(element.getAttribute("view")); state.setRedirect(element.getAttribute("redirect")); state.setPopup(element.getAttribute("popup")); state.setModel(element.getAttribute("model")); state.setValidationHints(element.getAttribute("validation-hints")); state.setVars(parseVars(element)); state.setBinder(parseBinder(element)); state.setOnRenderActions(parseOnRenderActions(element)); state.setAttributes(parseAttributes(element)); state.setSecured(parseSecured(element)); state.setOnEntryActions(parseOnEntryActions(element)); state.setExceptionHandlers(parseExceptionHandlers(element)); state.setTransitions(parseTransitions(element)); state.setOnExitActions(parseOnExitActions(element)); return state; }
public void merge(Model model) { ViewStateModel state = (ViewStateModel) model; setParent(null); setAttributes(merge(getAttributes(), state.getAttributes())); setSecured((SecuredModel) merge(getSecured(), state.getSecured())); setOnEntryActions(merge(getOnEntryActions(), state.getOnEntryActions(), false)); setExceptionHandlers(merge(getExceptionHandlers(), state.getExceptionHandlers())); setTransitions(merge(getTransitions(), state.getTransitions())); setOnExitActions(merge(getOnExitActions(), state.getOnExitActions(), false)); setView(merge(getView(), state.getView())); setRedirect(merge(getRedirect(), state.getRedirect())); setPopup(merge(getPopup(), state.getPopup())); setModel(merge(getModel(), state.getModel())); setValidationHints(mergeValidationHints(getValidationHints(), state.getValidationHints())); setVars(merge(getVars(), state.getVars(), false)); setBinder((BinderModel) merge(getBinder(), state.getBinder())); setOnRenderActions(merge(getOnRenderActions(), state.getOnRenderActions(), false)); }
public Model createCopy() { ViewStateModel copy = new ViewStateModel(getId()); super.fillCopy(copy); copy.setView(view); copy.setRedirect(redirect); copy.setPopup(popup); copy.setModel(model); copy.setValidationHints(validationHints); copy.setVars(copyList(vars)); copy.setBinder((BinderModel) copy(binder)); copy.setOnRenderActions(copyList(onRenderActions)); return copy; }
private void parseAndAddViewState(ViewStateModel state, Flow flow) { ViewFactory viewFactory = parseViewFactory(state.getView(), state.getId(), false, state.getBinder()); Boolean redirect = null; if (StringUtils.hasText(state.getRedirect())) { redirect = (Boolean) fromStringTo(Boolean.class).execute(state.getRedirect()); } boolean popup = false; if (StringUtils.hasText(state.getPopup())) { popup = ((Boolean) fromStringTo(Boolean.class).execute(state.getPopup())); } MutableAttributeMap<Object> attributes = parseMetaAttributes(state.getAttributes()); if (state.getModel() != null) { attributes.put( "model", getLocalContext().getExpressionParser().parseExpression(state.getModel(), new FluentParserContext().evaluate(RequestContext.class))); } if (state.getValidationHints() != null) { attributes.put("validationHints", getLocalContext().getExpressionParser().parseExpression(state.getValidationHints(), new FluentParserContext().evaluate(RequestContext.class))); } parseAndPutSecured(state.getSecured(), attributes); getLocalContext().getFlowArtifactFactory().createViewState(state.getId(), flow, parseViewVariables(state.getVars()), parseActions(state.getOnEntryActions()), viewFactory, redirect, popup, parseActions(state.getOnRenderActions()), parseTransitions(state.getTransitions()), parseExceptionHandlers(state.getExceptionHandlers(), state.getTransitions()), parseActions(state.getOnExitActions()), attributes); }
private static void createDuoLoginViewState(final List<AbstractStateModel> states) { val viewState = new ViewStateModel(STATE_ID_VIEW_LOGIN_FORM_DUO); viewState.setView("casDuoLoginView"); viewState.setModel(CasWebflowConstants.VAR_ID_CREDENTIAL); val bm = new BinderModel(); val bindings = new LinkedList<BindingModel>(); val bme = new BindingModel("signedDuoResponse", null, null); bindings.add(bme); bm.setBindings(bindings); viewState.setBinder(bm); val actions = new LinkedList<AbstractActionModel>(); actions.add(new EvaluateModel(ACTION_PREPARE_DUO_WEB_LOGIN_FORM_ACTION)); viewState.setOnEntryActions(actions); val trans = new LinkedList<TransitionModel>(); val transModel = new TransitionModel(); transModel.setOn(CasWebflowConstants.TRANSITION_ID_SUBMIT); transModel.setTo(CasWebflowConstants.STATE_ID_REAL_SUBMIT); transModel.setBind(Boolean.TRUE.toString()); transModel.setValidate(Boolean.FALSE.toString()); trans.add(transModel); viewState.setTransitions(trans); states.add(viewState); }
private static void createDuoRedirectToRegistrationAction(final List<AbstractStateModel> states) { val endModel = new ViewStateModel(VIEW_ID_REDIRECT_TO_DUO_REGISTRATION); endModel.setView("externalRedirect:#{flowScope.duoRegistrationUrl}"); states.add(endModel); }
public void testMergeStates() { FlowModel child = new FlowModel(); child.setStates(asList(new ViewStateModel("view"), new EndStateModel("end"))); FlowModel parent = new FlowModel(); ViewStateModel view = new ViewStateModel("view"); view.setView("jsp"); parent.setStates(asList(view, new DecisionStateModel("decider"), new ActionStateModel("action"))); child.merge(parent); assertEquals(4, child.getStates().size()); assertEquals("jsp", ((ViewStateModel) child.getStates().get(0)).getView()); }
public void testViewStateModelBinding() { ClassPathResource resource = new ClassPathResource("flow-viewstate-model-binding.xml", getClass()); FlowModelBuilder builder = new XmlFlowModelBuilder(resource, registry); builder.init(); builder.build(); FlowModel flow = builder.getFlowModel(); ViewStateModel model = (ViewStateModel) flow.getStates().get(0); assertEquals("formObject", model.getModel()); assertEquals("foo,bar", model.getValidationHints()); assertEquals("objectProperty", model.getBinder().getBindings().get(0).getProperty()); assertEquals("customConverter", model.getBinder().getBindings().get(0).getConverter()); }
public void testViewStatePopup() { ViewStateModel view = new ViewStateModel("view"); view.setPopup("true"); model.setStates(asList(view)); Flow flow = getFlow(model); assertTrue(((ViewState) flow.getStateInstance("view")).getPopup()); }
public void testViewStateRedirect() { ViewStateModel view = new ViewStateModel("view"); view.setRedirect("true"); model.setStates(asList(view)); Flow flow = getFlow(model); assertTrue(((ViewState) flow.getStateInstance("view")).getRedirect()); }
public void testNotMergeable() { ViewStateModel child = new ViewStateModel("child"); ViewStateModel parent = new ViewStateModel("parent"); assertFalse(child.isMergeableWith(parent)); }
public void testViewStateVariable() { ViewStateModel view = new ViewStateModel("view"); view.setVars(asList(new VarModel("foo", "org.springframework.webflow.TestBean"))); model.setStates(asList(view)); Flow flow = getFlow(model); assertNotNull(((ViewState) flow.getStateInstance("view")).getVariable("foo")); }
public void testSetActionWithResultType() throws Exception { SetModel setModel = new SetModel("flowScope.stringArray", "intArray"); setModel.setType("java.lang.String[]"); model.setOnStartActions(asList(setModel)); model.setStates(asList(new ViewStateModel("view"))); Flow flow = getFlow(model); AnnotatedAction action = (AnnotatedAction) flow.getStartActionList().get(0); MockRequestContext context = new MockRequestContext(flow); context.getFlowScope().put("intArray", new int[] { 1, 2 }); action.execute(context); String[] expected = (String[]) context.getFlowScope().get("stringArray"); assertEquals("1", expected[0]); assertEquals("2", expected[1]); }
private void parseAndAddViewState(ViewStateModel state, Flow flow) { ViewFactory viewFactory = parseViewFactory(state.getView(), state.getId(), false, state.getBinder()); Boolean redirect = null; if (StringUtils.hasText(state.getRedirect())) { redirect = (Boolean) fromStringTo(Boolean.class).execute(state.getRedirect()); } boolean popup = false; if (StringUtils.hasText(state.getPopup())) { popup = ((Boolean) fromStringTo(Boolean.class).execute(state.getPopup())).booleanValue(); } MutableAttributeMap attributes = parseMetaAttributes(state.getAttributes()); if (state.getModel() != null) { attributes.put("model", getLocalContext().getExpressionParser().parseExpression(state.getModel(), new FluentParserContext().evaluate(RequestContext.class))); } parseAndPutSecured(state.getSecured(), attributes); getLocalContext().getFlowArtifactFactory().createViewState(state.getId(), flow, parseViewVariables(state.getVars()), parseActions(state.getOnEntryActions()), viewFactory, redirect, popup, parseActions(state.getOnRenderActions()), parseTransitions(state.getTransitions()), parseExceptionHandlers(state.getExceptionHandlers(), state.getTransitions()), parseActions(state.getOnExitActions()), attributes); }
public Model createCopy() { ViewStateModel copy = new ViewStateModel(getId()); super.fillCopy(copy); copy.setView(view); copy.setRedirect(redirect); copy.setPopup(popup); copy.setModel(model); copy.setValidationHints(validationHints); copy.setVars(copyList(vars)); copy.setBinder((BinderModel) copy(binder)); copy.setOnRenderActions(copyList(onRenderActions)); return copy; }
public void testViewStateFlowRedirect() { ViewStateModel state = new ViewStateModel("view"); state.setView("flowRedirect:myFlow?input=#{flowScope.foo}"); model.setStates(asList(state)); Flow flow = getFlow(model); ViewFactory vf = ((ViewState) flow.getStateInstance("view")).getViewFactory(); assertTrue(vf instanceof ActionExecutingViewFactory); ActionExecutingViewFactory avf = (ActionExecutingViewFactory) vf; assertTrue(avf.getAction() instanceof FlowDefinitionRedirectAction); }
public void testNotMergeableWithNull() { ViewStateModel child = new ViewStateModel("child"); assertFalse(child.isMergeableWith(null)); }
public void testEvaluateActionWithResultType() throws Exception { EvaluateModel evaluateModel = new EvaluateModel("testBean.getIntegers()"); evaluateModel.setResult("flowScope.stringArray"); evaluateModel.setResultType("java.lang.String[]"); model.setOnStartActions(asList(evaluateModel)); model.setStates(asList(new ViewStateModel("view"))); Flow flow = getFlow(model); AnnotatedAction action = (AnnotatedAction) flow.getStartActionList().get(0); MockRequestContext context = new MockRequestContext(flow); context.getFlowScope().put("testBean", new TestBean()); action.execute(context); String[] expected = (String[]) context.getFlowScope().get("stringArray"); assertEquals("1", expected[0]); assertEquals("2", expected[1]); }
public void merge(Model model) { ViewStateModel state = (ViewStateModel) model; setParent(null); setAttributes(merge(getAttributes(), state.getAttributes())); setSecured((SecuredModel) merge(getSecured(), state.getSecured())); setOnEntryActions(merge(getOnEntryActions(), state.getOnEntryActions(), false)); setExceptionHandlers(merge(getExceptionHandlers(), state.getExceptionHandlers())); setTransitions(merge(getTransitions(), state.getTransitions())); setOnExitActions(merge(getOnExitActions(), state.getOnExitActions(), false)); setView(merge(getView(), state.getView())); setRedirect(merge(getRedirect(), state.getRedirect())); setPopup(merge(getPopup(), state.getPopup())); setModel(merge(getModel(), state.getModel())); setVars(merge(getVars(), state.getVars(), false)); setBinder((BinderModel) merge(getBinder(), state.getBinder())); setOnRenderActions(merge(getOnRenderActions(), state.getOnRenderActions(), false)); }
private ViewStateModel parseViewState(Element element) { ViewStateModel state = new ViewStateModel(element.getAttribute("id")); state.setParent(element.getAttribute("parent")); state.setView(element.getAttribute("view")); state.setRedirect(element.getAttribute("redirect")); state.setPopup(element.getAttribute("popup")); state.setModel(element.getAttribute("model")); state.setVars(parseVars(element)); state.setBinder(parseBinder(element)); state.setOnRenderActions(parseOnRenderActions(element)); state.setAttributes(parseAttributes(element)); state.setSecured(parseSecured(element)); state.setOnEntryActions(parseOnEntryActions(element)); state.setExceptionHandlers(parseExceptionHandlers(element)); state.setTransitions(parseTransitions(element)); state.setOnExitActions(parseOnExitActions(element)); return state; }