在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) {
...
}
}
本文介绍了在Seam框架中使用Richfaces的listShuttle组件时需要注意的问题,特别是当使用自定义转换器(converter)时,为了确保源列表和目标列表中的对象能够正确地进行比较和操作,这些对象必须实现hashCode()和equals()方法。
2778

被折叠的 条评论
为什么被折叠?



