All 3 entries tagged Spring Webflow

No other Warwick Blogs use the tag Spring Webflow on entries | View entries tagged Spring Webflow at Technorati | There are no images tagged Spring Webflow on this blog

June 08, 2005

Interesting problem editing a "dynamic" object model

So I have the following object model:

ObjectA has an instance of ObjectB

There are multiple implementations of ObjectB, all with different properties.

How do you handle the binding when the implementation of ObjectB needs to be determined at run time?

I ended up having a Form which contains accessors for all possible values of all the implementations of ObjectB and an apply() method. Form is constructed with an instance of Object A and initialises itself based on the current implementation of ObjectB. Page is rendered, when introspected all values are introspected onto FormA, or FormA.getObjectA, and after introspection FormA.apply, and ObjectA = FormA.getObjectA is called.

All validators etc. work directly on ObjectA, not FormA, but the validators know how to validate the different implementations of ObjectB.

Not particularly nice or elegant, but how else can we do it?

I could implement my own Binder, but that doesn't help the problem of rendering the page, with all possible alternate properties. You cannot bind to attributes that don't exist, and I don't want chunks of jsp that are conditional on the implementation of ObjectB.

An example of what I am wittering on about is say you have a person who has a mode of transport. One implementation of transport is train, with platform, station, time etc. Another implementation is Car with make, model, year etc.

The page that edits Person allows you to specify the mode of transport.

June 02, 2005


Follow-up to My initial impressions from Colin's blog

So I worked around the request attributes problem by registering a FlowExecutionListener with the ServletFlowManager.

The listener actually does the following:

—— code ——
public void sessionStarting(final RequestContext context, final State startState, final Map input) {

public void requestSubmitted(final RequestContext context) {

private void copyAttributes(final RequestContext context) {
ServletRequest request = ((ServletEvent)context.getSourceEvent()).getRequest();
for (String name: names) {
context.getRequestScope().put(name, request.getAttribute(name));

—— code ——

I don't think this is something we should have to do though, and there is undoubtedly a "better way", but until I find it….

My initial impressions

Writing about web page

So I have just started using Spring webflow. Mixed feelings at the moment; it certainly promises to be an excellent piece of software if done right, but it is just a bit too painful to get things going.

First off, there is no ServletRequest or ServletResponse to play with. Yep, they have been replaced with a RequestContext. This is so the framework can be used in non-servlet based environments, i.e. portals.

The problem is that every single web app I have ever made (including those that use Spring MVC) all access the ServletRequest and ServletResponse!

(This is only really a problem if you are integrating webflow into an existing web app)

Another problem I came across is that the RequestContext doesn't seem to be able to pick up on existing request attributes. This is a bit of a problem as I quite often use filters to set certain attributes!

Oh well, it is certainly worth fighting the pain for because I think the end solution will be excellent, but there is certainly a lot of pain!

November 2021

Mo Tu We Th Fr Sa Su
Oct |  Today  |
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30               

Search this blog



Most recent comments

  • Interesting… While I'm not completely convinced in such microbenchmarks, I'm pretty sure that 1ms … by Alexander Snaps on this entry
  • Hello. I bought the book yesterday. I was trying to find the source code for chapter 11 and chapter … by Suleman on this entry
  • by live mashup demo on this entry
  • Thanks mate ….. This blog was really helpful. by Maaz Hurzuk on this entry
  • Ty. Not directly helpful for my problem, but pointed me in the right direction. You will also get th… by Mike E. on this entry

Blog archive

RSS2.0 Atom
Not signed in
Sign in

Powered by BlogBuilder