1
NativeSelect에 값을 설정하고 Select 필드에 항목을 추가하는 동안 i가 표시 할 항목을 설정해야합니다. 내가 달성해야하는지에 대한 좋은 예로서이를 가정 할 수있다 :Java - Vaadin : NativeSelect setValue가 작동하지 않습니다.
public class TestselectUI extends UI {
@Override
protected void init(VaadinRequest request) {
final VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
setContent(layout);
NativeSelect sel = new NativeSelect();
Customer c1 = new Customer("1", "Pippo");
Customer c2 = new Customer("2", "Pluto");
Customer c3 = new Customer("3", "Paperino");
Customer c4 = new Customer("4", "Pantera");
Customer c5 = new Customer("5", "Panda");
sel.addItem(c1);
sel.addItem(c2);
sel.addItem(c3);
sel.addItem(c4);
sel.addItem(c5);
Customer test = new Customer(c4.id, c4.name);
sel.setValue(test);
layout.addComponent(sel);
}
private class Customer {
public String id;
public String name;
/**
* @param id
* @param name
*/
public Customer(String id, String name) {
super();
this.id = id;
this.name = name;
}
@Override
public String toString() {
return this.name;
}
@Override
public boolean equals(final Object object) {
// return true if it is the same instance
if (this == object) {
return true;
}
// equals takes an Object, ensure we compare apples with apples
if (!(object instanceof Customer)) {
return false;
}
final Customer other = (Customer) object;
// implies if EITHER instance's name is null we don't consider them equal
if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
}
}
내 문제는되지 올바르게 설정하고 항상 널 끈다의 값. 이 문제에 대한 유용한 정보가 있습니까?
당신은 내 아이돌입니다! :) 고마워요. –