在Seam中使用Richfaces的listShuttle控件时,如果使用了converter需要注意一点,在sourceValue和targetValue中的对象,必须实现hashCode() 和 equals() 方法。
@Name("productConverter")
@Converter(id = "productConverter")
public class ProductConverter implements javax.faces.convert.Converter {
public Object getAsObject(FacesContext context, UIComponent component, String value) {
ProductBean bean = new ProductBean();
bean.setProductId(value);
return bean;
}
public String getAsString(FacesContext context, UIComponent component, Object value) {
ProductBean optionItem = (ProductBean) value;
return optionItem.getProductId();
}
}
public class ProductBean implements Serializable {
...
@Override
public int hashCode() {
...
}
@Override
public boolean equals(Object obj) {
...
}
}