We’re going to do unit tests on some parts at work. This should make it easier. I’ll have to check it out later.
Via java.no.
At work I haven been pounding out Struts based pages lately. We are building a registration system basically, with some intrisic rules for submitting data and checking with external systems. From my work with Struts at UKA I knew multipage forms were a common problem with Struts. Henning hacked his way around it some way, but I didn’t have to figure it out then.
Struts 1.2 is in the pipeline. It’s running at version 1.2.1 Beta and features several improvements, including support for multipage forms.
The biggest problem with multipage forms were actually the validation. You couldn’t validate the form partially for the first page, and the rest on the second page. This has been solved through the page=”” attribute on the field element in validation.xml. When validation is triggered it will validate the data for the current page AND all pages with a lower number. So this means that if data was validated on page one, it will be validated again together with the data from page two. This also means that if you have implemented your form reset method correctly you will need to include the fields from the previous forms as hidden fields in the current page.
The way Struts keeps track of which page you are on is through the page form attribute. This is just a normal form-field, but its name is required to be page. They should probably have chosen a less generic name for it like struts.form.page or something, but I guess it works fine. It is normally implemented through html:hidden.
Surfing through Brooch i found this site with Java design patterns. It relates most of the GoF book to links describing it in java, and with additional information. Great resource.