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)); }
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); }
public void testStateMerge() { ClassPathResource resourceChild = new ClassPathResource("flow-inheritance-state-child.xml", getClass()); ClassPathResource resourceParent = new ClassPathResource("flow-inheritance-state-parent.xml", getClass()); registry.registerFlowModel("child", new DefaultFlowModelHolder(new XmlFlowModelBuilder(resourceChild, registry))); registry.registerFlowModel("parent", new DefaultFlowModelHolder(new XmlFlowModelBuilder(resourceParent, registry))); FlowModel flow = registry.getFlowModel("child"); assertEquals(1, flow.getStates().size()); assertEquals("otherview", ((ViewStateModel) flow.getStates().get(0)).getView()); }
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()); }
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); }
assertEquals("fooModel", child.getModel()); assertEquals("foo", child.getValidationHints()); assertEquals("fooView", child.getView()); assertEquals("bar", child.getAttributes().get(0).getValue()); assertEquals("foo", child.getBinder().getBindings().get(0).getProperty());
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)); }
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)); }
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); }