numerous binding fixes, see changelog
This commit is contained in:
@@ -1,5 +1,31 @@
|
||||
package org.springframework.webflow.samples.booking;
|
||||
|
||||
public enum Amenity {
|
||||
OCEAN_VIEW, LATE_CHECKOUT, MINIBAR;
|
||||
}
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Amenity implements Serializable {
|
||||
|
||||
private String name;
|
||||
|
||||
public Amenity(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof Amenity)) {
|
||||
return false;
|
||||
}
|
||||
Amenity a = (Amenity) obj;
|
||||
return name.equals(a.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return name.hashCode();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,6 +13,7 @@ public class ApplicationConversionService extends DefaultConversionService {
|
||||
StringToDate dateConverter = new StringToDate();
|
||||
dateConverter.setPattern("MM-dd-yyyy");
|
||||
addConverter("shortDate", dateConverter);
|
||||
addConverter(new StringToAmenity());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import java.math.BigDecimal;
|
||||
import java.text.DateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.Basic;
|
||||
@@ -186,6 +187,12 @@ public class Booking implements Serializable {
|
||||
}
|
||||
|
||||
public void setAmenities(Set<Amenity> amenities) {
|
||||
Iterator<Amenity> it = amenities.iterator();
|
||||
while (it.hasNext()) {
|
||||
Object a = it.next();
|
||||
System.out.println(a);
|
||||
System.out.println(a.getClass());
|
||||
}
|
||||
this.amenities = amenities;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package org.springframework.webflow.samples.booking;
|
||||
|
||||
import org.springframework.binding.convert.converters.StringToObject;
|
||||
|
||||
public class StringToAmenity extends StringToObject {
|
||||
|
||||
public StringToAmenity() {
|
||||
super(Amenity.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object toObject(String string, Class tagetClass) throws Exception {
|
||||
return new Amenity(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String toString(Object value) throws Exception {
|
||||
return ((Amenity) value).getName();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,7 +26,8 @@
|
||||
|
||||
<!-- Configures Web Flow to use Tiles to create views for rendering; Tiles allows for applying consistent layouts to your views -->
|
||||
<bean id="mvcViewFactoryCreator" class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator">
|
||||
<property name="viewResolvers" ref="tilesViewResolver"/>
|
||||
<property name="viewResolvers" ref="tilesViewResolver"/>
|
||||
<property name="useSpringBeanBinding" value="true" />
|
||||
</bean>
|
||||
|
||||
<!-- Installs a listener that manages JPA persistence contexts for flows that require them -->
|
||||
|
||||
Reference in New Issue
Block a user