Monday, December 12, 2005

Wizards, Warlocks, Sorcerers and Mages

Over the last couple of weeks I have been writing a multi-page wizard application with a database backend. This has been a learning opportunity for me to look into technologies like Spring and iBATIS to see what they could offer me in this and future endeavours. The next few blog entries will discuss what I have learned so far about Wizards, Spring and finally iBATIS. Firstly a very quick look at the Wizard solutions I found and eventually discarded.

I wanted to write a simple multi-page wizard and decided to see what was available to make my life easier. There is a subtle difference between a web wizard and full workflow. I found that solutions that were designed for proper workflow that include support for state, events, versioning and resource management were too heavyweight for a simple web wizard application.

Struts Flow

Struts flow uses JSON to define the flow between web pages. On this occasion I didn't like the idea of having to define functionality in server side JavaScript. I decided against this approach because I want a simple solution and I want my colleagues to understand it. My colleagues are happy enough for me to wax lyrical about the pleasures of AJAX, BSF, Rhino, E4X etc. as long as they don't have to use it.

EasyWizard

I then looked at using EasyWizard (See also these articles [1], [2]). I liked the basic approach. I saw merit in the fact you can test the state transition in isolation. However, I didn't like the idea of hard coding the flow into Java classes something about this just felt wrong.

Spring Web Flow

I looked at Spring Web Flow, I liked the idea of being able to define the flow in a separate XML file. Although it seemed you couldn't easily get the same flexibility into the flows as you could with EasyWizard. It was promising but still not the simple solution I was hoping to find.

Spring's AbstractWizardFormController

Spring has a built in mechanism called AbstractWizardFormController. I found one very simple example of its usage, I couldn't find any further examples or documentation so I abandoned using it.

Decision

My final decision was not to use any special wizard framework. I wanted to keep it simple and none of the above solutions were that simple or for my needs justified the extra effort to seem worthwhile. It seemed simpler to me to implement my wizard in Struts.

6 comments:

Mark McLaren said...

Hi



I happen to see your blog today and it is very informative and useful. I have a quick question. I am working on a Spring , JSF , Hibernate application which consists of Wizard type of web flow functionality. Initially I thought of using Spring Webflow, but after seeing your post, I have other thoughts.



I am impressed by your decision not to use any special wizard framework to keep it simple. Can you please suggest your simple approach implemntaion so that I want get a clue from yours to implement the same in my application.



Thank you and regards,

Venus.
Note: Comment imported. Original by Anonymous at 2006-01-11 16:44

Mark McLaren said...

Hi Venus



I'm glad you found this useful. I think I need to explain a few things about my current situation and thinking.



I am new to Spring but have been using Struts for a little while now. I am quite comfortable producing simple Struts applications and find it quite easy to knock up very simple wizard-like applications (what I refer to as functionality free prototypes, i.e. you can navigate through the application but it doesn't do very much). See this previous article I wrote about writing basic Struts apps using the Camino Struts IDE. My wizard app is a bog standard MVC Struts app really and as such is quite easy to produce although it is situation specific.



I presume that with a similar JSF IDE it would be really easy to create an MVC JSF application. I have previously briefly toyed with Java Studio Creator 2 (Early Access) and my impression of it is that this tool could be used to knock out JSF based apps at speed.



I feel that if you try and use the most generic approaches all the time, and don't know exactly what you are doing, you can end up with unnecessarily complicated web applications. As Einstein said Things should be made as simple as possible -- but no simpler. I generally find simple is best and I feel that the Wizard approaches that I looked at above are more complicated approaches than I needed when compared with a straight forward Struts app.



That said, I am very impressed with some aspects of Spring such as the DAO related stuff, as you can see from my other iBATIS related entries (there are equivalent mechanisms for Hibernate documented in many other places). I have yet to be convinced of the benefits of Spring MVC but it is something I do plan on investigating more fully at some point.


Note: Comment imported. Original by markmc website: http://cse-mjmcl.cse.bris.ac.uk/blog at 2006-01-11 18:49

Mark McLaren said...

Hi ,

I am new to spring framework . I wanted to used some kind of workflow engine with spring . pls help me with the best approach




Note: Comment imported. Original by Bhushan at 2006-02-28 07:48

Mark McLaren said...

Hi Bhushan,



I'm not sure I am the right person to ask about this! For the above solution I chose to use Struts (I like and understand what Struts is about). I am a big fan of certain aspects of the Spring Framework but I'm currently struggling to appreciate Spring MVC! However, this could be because I'm only really interested in learning about Spring Portlet MVC. To my inexperienced eye the Spring Portlet MVC looks like an evil hybrid of the Portlet API and Spring MVC.





Anyway, back to your question. If you've already decided on using Spring MVC I think you have two choices. For a very simple wizard you could write a class that extends the AbstractWizardFormController. For more complex behaviour you may be better off choosing Spring Web Flow framework.





Incidentally, not long after writing the above blog entry I got an e-mail directly from Keith Donald, co-lead of Spring Web Flow asking me what I didn't like about his framework!! (scary huh!!). I put some naive questions to Keith and he gave me some rather expert replies which I haven't got around to blogging about yet. That'll teach me to express my views online!


Note: Comment imported. Original by markmc website: http://cse-mjmcl.cse.bris.ac.uk/blog at 2006-02-28 13:32

Mark McLaren said...

Hi ,

Thanks for your sugesstion. I want to know how to implement WorkFlow (e.g Trouble Ticket Workflow) using Spring WebFlow.
Note: Comment imported. Original by Bhushan at 2006-03-04 08:45

Mark McLaren said...

Hi Bhushan

In the above blog entry I'm more interested in simple wizard webflow than actual workflow. I'm not well schooled on the best workflow engines, a reasonable place to start your investigations would be Java-Source.net's Open Source Workflow Engines in Java section.
Note: Comment imported. Original by markmc website: http://cse-mjmcl.cse.bris.ac.uk/blog at 2006-03-04 11:17