gregsoulsby (30) [Avatar] Offline
#1
Ken,

The book mentions webflows, but does not go into details. I think webflow is very important - I wish Roo generated its view layer in it rather than controllers.

The Roo generation of the skelleton flow works fine.

My problem is how to use the Roo generated classes in a flow.

Within say <on-start> the expression might be

expression="new com.a.b.repositiory.MyclassRepository()"

but this gives me a message about invalid constructor.

When I bring in a service I get null pointer exception on things autowired, which I take to mean they are not being autowired.

There is a "bean" option on the STS webflow form, but this invalidates the flow.xml.

Can you advise on optons?

Greg
ken.rimple (246) [Avatar] Offline
#2
Re: Getting workflow going - how to?
Key things:

1) In your expression evaluations, you will use the component name of the @Component or @Service you're trying to inject. It lowercases the first letter, and names it on the class you annotate, so if you have:

@Component
public class AccountManagerImplBean implements AccountManager

the name will be accountManagerImplBean.

You can override with

@Component("accountManager")

You do not reference a new of anything, nor the package/class name. it has to be a Spring Bean in this case above.

2) Spring will import everything into the naming space - including the bean names of the spring context, all of the scopes (request, session, flow and other scopes) etc... So it should find the bean.

3) You can treat the expressions like other ELs. In the Spring WebFlow guide I believe it lists some sample expressions.

4) You do not need to instantiate the Spring beans in the on-start. Unless you want to create your own bean of a particular instance (for state information), don't bother. They will be injected.

So you can do:

<on-start>
<evaluate expression="myRepository.findAllCheeseburgers()" result="flowScope.cheeseburgerList" />
</on-start>

You can also pass it flowRequestContext, which is a variable of type RequestContext. This contains all scope data so you can then pluck out a scope in your bean method and store / get things from it. See

http://java.dzone.com/news/webflow-roo-again-more-complex

Ken

Message was edited by:
ken.rimple
gregsoulsby (30) [Avatar] Offline
#3
Re: Getting workflow going - how to?
Ken,

You are both fast and good.

Many thanks, that is more than helpful.

Greg
ken.rimple (246) [Avatar] Offline
#4
Re: Getting workflow going - how to?
I'll take that compliment!

Any time, Greg!

Best,

Ken