Man*_*tha 13 java gwt google-app-engine
我是GWT的新手.我正在编写一个简单的GWT程序,我需要使用一个组合框,我使用了一个实例ValueListBox.在那个组合中,我需要列出1到12之间的数字,代表一年中的几个月.但是这个组合null最后增加了价值.任何人都可以帮我如何删除该null值?
final ValueListBox<Integer> monthCombo = new ValueListBox<Integer>(new Renderer<Integer>() {
@Override
public String render(Integer object) {
return String.valueOf(object);
}
@Override
public void render(Integer object, Appendable appendable) throws IOException {
if (object != null) {
String value = render(object);
appendable.append(value);
}
}
});
monthCombo.setAcceptableValues(getMonthList());
monthCombo.setValue(1);
private List<Integer> getMonthList() {
List<Integer> list = new ArrayList<Integer>();
for (int i = 1; i <= 12; i++) {
list.add(i);
}
return list;
}
Run Code Online (Sandbox Code Playgroud)

Tho*_*yer 25
setValue之前打电话setAcceptableValues.
原因是该值是null您调用时setAcceptableValues,并ValueListBox自动将任何值(通常传递给setValue)添加到可接受值列表中(以便实际设置该值,并且可以由用户选择,如果她已重新选择)选择了另一个值并希望返回原始值.setValue首先使用将在可接受值列表中的值调用会抵消此副作用.
请参阅http://code.google.com/p/google-web-toolkit/issues/detail?id=5477
| 归档时间: |
|
| 查看次数: |
4439 次 |
| 最近记录: |