Its all about the wizards - No Fluff Just Stuff

Its all about the wizards

Posted by: Andres Almiray on October 13, 2007

No I'm not talking about Harry Potter and their ilk but one of JMatter's many features, that's right, wizards that let you configure your domain classes in an easy way. If you're into Java desktop programming you owe to yourself to take a look at what the framework has to offer (hint: check the latest article by Eitan). Alright on with the topic, before the feature I'm about to introduce, the way to code wizards was pretty straight forward but as your domain class grew so did your wizard code, and it lend itself to repetition, as we are against DRY, DomainWizard was born.

This little guy will let you build a wizard in a breeze and at the same time opens the door for customization without changing a line of code. All of the labels and descriptions are pulled from the domain class metadata and a resource file, simple, easy, agile!. Let's see an example with a before/after approach, this is what a normal wizard used to look:

Direct to the point but notice that each composite attribute requires similar setup, surely we can do better than that, let's see DomainWizard (the after way)

Notice it only takes 6 lines in average to do the same (albeit some lines in a properties file too). Notice also that the keys in the properties file follow a naming convention, which will help you configure properties with the same name belonging to different classes.

JMatter's wizards are a little bit more sophisticated that what we have seen so far, DomainWizard is only useful for building domain classes following the same recipe. But what if you require a different set of steps or perhaps conditional steps? JMatter provides those steps already but Groovy can help make the job easier don't you think? thanks to the power of builders we now have WizardBuilder. Let's see how the previous code looks with WizardBuilder in place

Just to show how conditional steps are declared let's pretend that the first two steps should belong to a group and if those steps are fulfilled then we can proceed to the last:

There are more ways to configure steps, specially the commit one, but that info belongs in the JMatter manual (note to self, get back to writing that stuff ASAP). You will find these and other exciting features at current SVN head, Eitan has been busy the last weeks but expect a new release in the following weeks (hopefully days ;-)). Oh and by the way, there is a really sweet surprise that Eitan managed to squeeze in, let's just say for now that it will surely put JMatter "on the map" ;-)
Andres Almiray

About Andres Almiray

Andres is a Java/Groovy developer and a Java Champion with more than 20 years of experience in software design and development. He has been involved in web and desktop application development since the early days of Java. Andres is a true believer in open source and has participated on popular projects like Groovy, Griffon, and DbUnit, as well as starting his own projects (Json-lib, EZMorph, GraphicsBuilder, JideBuilder). Founding member of the Griffon framework and Hackergarten community event. https://ch.linkedin.com/in/aalmiray

Why Attend the NFJS Tour?

  • » Cutting-Edge Technologies
  • » Agile Practices
  • » Peer Exchange

Current Topics:

  • Languages on the JVM: Scala, Groovy, Clojure
  • Enterprise Java
  • Core Java, Java 8
  • Agility
  • Testing: Geb, Spock, Easyb
  • REST
  • NoSQL: MongoDB, Cassandra
  • Hadoop
  • Spring 4
  • Cloud
  • Automation Tools: Gradle, Git, Jenkins, Sonar
  • HTML5, CSS3, AngularJS, jQuery, Usability
  • Mobile Apps - iPhone and Android
  • More...
Learn More »