我有一个这样的原生选择:
occupationSelect = new NativeSelect("Occupation:");
occupationSelect.setRequired(true);
occupationSelect.setRequiredError("Must Not be Empty");
occupationSelect.setImmediate(true);
occupationSelect.setWidth(COMMON_FIELD_WIDTH);
occupationSelect.setNullSelectionItemId(0);
occupationSelect.setItemCaption(0, "--Select");
occupationSelect.addItem(1);
occupationSelect.setItemCaption(1, "static");
在模态类Registration.java
中 private OccupationBean occupationBean;
OccupationBean.java
private Long occupationId;
private String occupationName;
绑定此字段
binderFieldGroupPersonalDetails.bind(occupationSelect,
"occupationBean.occupationId");
我收到此错误:
无法将java.lang.Integer类型的值转换为模型类型类java.lang.Long。没有设置转换器且类型不兼容。
没有IntegerToLong的默认转换器
我该如何实现这个
答案 0 :(得分:3)
只需使用0L而不是0
occupationSelect.setNullSelectionItemId(0L);
occupationSelect.setItemCaption(0L, "--Select");
occupationSelect.addItem(1L);
occupationSelect.setItemCaption(1L, "static");