QWicket is a project that is hosted on the SourceForge servers, and promises rapid development for your Wicket applications. Can’t wait to download the first release!
It is nice to see more and more projects spawning to aid the development of Wicket applications. Next to our community projects hosted on Wicket Stuff, we already have projects for IDE support (Eclipse and NetBeans), we have Databinder for quick Hibernate applications, and now QWicket.
The functional web application testing framework jWebUnit has released the second release candidate for the revival release 1.3. New fixes to the first release candidate are:
Show the getTable() method in WebTestCase to allow custom assertions. Thanks to Tetyana Gimgina
Introduce the setFormElement() back as a deprecated method that wraps setTextField(). Fixes 1517851. Thanks to Tetyana Gimgina
Update to HtmlUnit 1.9.
Allow selection of forms with same name (with index).
Add setWorkingForm(String nameOrId, int index) to the API. Fixes 1515297. Thanks to Jeffrey W. Badorek
A regular question on the Wicket mailinglist is how to pre-select a value in a drop down box.
If you look at the following select box, you see that I’ve pre-selected the value ‘female’, while the value ‘male’ is first in line.
Example code:
Gender:
Example:
Gender: malefemale
Typically you’ll select an object value from a list, or an enum value (Java 5) from the list. First, lets create the enum for Gender:
public enum Gender {
male, female;
}
Now if we have a form that allows you to change the gender of a person using a drop down choice, this would typically look like the following example:
form.add(new DropDownChoice(
"gender",
new PropertyModel(person, "gender"),
Arrays.asList(Gender.values())));
So how do we make sure that female is the default choice? As you can see, the component has a property model as its model, and it is bound to the gender of the person. By setting the gender of the person to ‘female’ the drop down choice box will select that value when it is rendered.
person.setGender(Gender.female);
New users of the Wicket framework typically try to use an interaction based approach when working with components. This is typically done by setting a value on the component, and in the submit handler querying the component for the value. Often people use String values to put in the component and retrieve from, having to do type conversion and checking themselves. This circumvents a lot of basic features Wicket provides to you. If you use the model based approach as shown in the example above, you will get automatic type conversions, automatic setting of values and validation.