PDA

View Full Version : Migrating PR5->1.0EA with AbstractFlowBuilder extender


balimis
Apr 3rd, 2006, 06:52 AM
Hi,
in PR5 i have developed wizard webflow template which i can not port into 1.0EA. Here are details:

PR5
webflow controller:
<bean id="webflowController" class="org.springframework.webflow.mvc.FlowController"/>

flow def. example:
<bean id="book-reward" class="org.springframework.webflow.config.FlowFactoryBean">
<property name="flowBuilder">
<bean class="...servlet.webflow.OneStepWizardFlowBuilder">
<property name="firstView" value="bookreward"/>
<property name="finalView" value="bookreward-finish"/>
<property name="firstAction" value="bookPrepareAction"/>
<property name="preValidation" value="true"/>
</bean>
</property>
</bean>

OneStepWizardFlowBuilder extends org.springframework.webflow.config.AbstractFlowBui lder by overriding buildStates() method.

Main idea is to define wizard definitions as spring beans with the same flow definition constructed in OneStepWizardFlowBuilder - so no flow.xml is needed, only step views and validation, submit actions wiring.



Now in 1.0EA i can not understand how can i make the same construction. I'm trying this way, but cannot make it working:

<bean id="webflowController" class="org.springframework.webflow.executor.mvc.FlowContr oller">
<property name="flowExecutor" ref="flowExecutor"/>
</bean>

<bean id="flowExecutor" class="org.springframework.webflow.executor.FlowExecutorI mpl">
<constructor-arg >
<ref bean="flowRegistry"/>
</constructor-arg>
<property name="alwaysRedirectOnPause" value="true"/>
</bean>

<bean id="flowRegistry" class="org.springframework.webflow.registry.FlowRegistryF actoryBean">
<property name="flowRegistrars">
<list>
<ref bean="flowRegistrar" />
</list>
</property>
</bean>

<bean id="flowRegistrar" class="...servlet.utils.MyFlowRegistrar"/>

<bean id="book-reward" class="org.springframework.webflow.builder.FlowAssembler">
<constructor-arg value="book-reward"/>
<constructor-arg>
<bean class="...servlet.webflow.OneStepWizardFlowBuilder" autowire="byType">
<property name="firstView" value="bookreward"/>
<property name="finalView" value="bookreward-finish"/>
<property name="firstAction" value="prepareAction"/>
<property name="preValidation" value="true"/>
</bean>
</constructor-arg>
</bean>

and in MyFlowRegistrar.class:
public void registerFlows(FlowRegistry registry, FlowArtifactFactory flowArtifactFactory) {
Map beansMap = this.getApplicationContext().getParent().getBeansO fType(FlowAssembler.class);//getParent gives appContext initiated in web.xml
for (Iterator iter = beansMap.keySet().iterator(); iter.hasNext();) {
String beanName = (String) iter.next();
FlowAssembler flowAssembler = (FlowAssembler) beansMap.get(beanName);
registry.registerFlow(new RefreshableFlowHolder(flowAssembler));
}
}


but have exception:

org.springframework.webflow.FlowArtifactException: Unable to lookup action with
id 'prepareAction'; action lookup is not supported by this arti
fact factory
at org.springframework.webflow.builder.DefaultFlowArt ifactFactory.getAct
ion(DefaultFlowArtifactFactory.java:82)
at org.springframework.webflow.builder.AbstractFlowBu ilder.action(Abstra
ctFlowBuilder.java:460)
at ....servlet.webflow.OneStepWizardFlowBuilder.build S
tates(OneStepWizardFlowBuilder.java:47)


thanks in advance for any help,
Bali

balimis
Apr 3rd, 2006, 11:29 AM
updating MyFlowRegistrar.class with code:

public void registerFlows(FlowRegistry registry, FlowArtifactFactory flowArtifactFactory) {
Map beansMap = this.getApplicationContext().getBeansOfType(FlowAs sembler.class);
for (Iterator iter = beansMap.keySet().iterator(); iter.hasNext();) {
String beanName = (String) iter.next();
FlowAssembler flowHolder = (FlowAssembler) beansMap.get(beanName);
((AbstractFlowBuilder)flowHolder.getFlowBuilder()) .setFlowArtifactFactory(flowArtifactFactory);
registry.registerFlow(this.createFlowHolder(flowHo lder));
}
}

causes following exception:
java.lang.NullPointerException
at org.springframework.webflow.action.MultiAction$Def aultActionMethodRes
olver.resolveMethod(MultiAction.java:176)
at org.springframework.webflow.action.MultiAction.doE xecute(MultiAction.
java:140)
at org.springframework.webflow.action.AbstractAction. execute(AbstractAct
ion.java:67)
at org.springframework.webflow.ActionExecutor.execute (ActionExecutor.jav
a:54)
at org.springframework.webflow.ActionState.doEnter(Ac tionState.java:184)

at org.springframework.webflow.State.enter(State.java :201)
at org.springframework.webflow.Flow.start(Flow.java:5 31)
at org.springframework.webflow.execution.impl.FlowExe cutionControlContex
tImpl.start(FlowExecutionControlContextImpl.java:1 87)
at org.springframework.webflow.execution.impl.FlowExe cutionImpl.start(Fl
owExecutionImpl.java:175)

Bali