Expert Spring MVC and Web Flow

(Dana P.) #1

Listing 6-22.MultiTypeCommandBean Class


public class MultiTypeCommandBean {


private int intProperty;
private Integer integerProperty;
private Class classProperty;
private URL urlProperty;

public Class getClassProperty() {
return classProperty;
}
public void setClassProperty(Class classProperty) {
this.classProperty = classProperty;
}
public Integer getIntegerProperty() {
return integerProperty;
}
public void setIntegerProperty(Integer integerProperty) {
this.integerProperty = integerProperty;
}
public int getIntProperty() {
return intProperty;
}
public void setIntProperty(int intProperty) {
this.intProperty = intProperty;
}
public URL getUrlProperty() {
return urlProperty;
}
public void setUrlProperty(URL urlProperty) {
this.urlProperty = urlProperty;
}
}


Using the command bean in Listing 6-22, we have four different properties, each of differ-
ent types, including intProperty, which is a primitive.
We are simulating the following form, shown in Listing 6-23, with the unit test. Note that
input fields for the HTML form are handled like regular text inputs. The actual conversion
happens inside the DataBinder.


Listing 6-23.MultiTypeCommandBean HTML Form




Int Property:



CHAPTER 6 ■THE CONTROLLER MENAGERIE 137
Free download pdf