3
组合框的实例是全局创建的,它充满了,可以说是公司列表,而值是一个ID。加载文件后,我想检查组合框中是否有该值,然后以编程方式选择它。Vaadin在组合框填充后设置组合框的值
class cComboBoxFun extends UI implements ClickListener
{
ComboBox cb_company;
List<cCustomer> ListCust;
//default constructor and server conf not really relevant
@Override
protected void init(VaadinRequest request)
{
//Lets assume the list has been filled already
cb_company = new ComboBox("Company");
for(cCustomer cust : ListCust)
{
cb_company.addItem(cust.mgetId);
cb_company.setItemcaption(cust.mgetId, cust.mgetName);
}
}
class cCustomer()
{
private String name;
private String Id;
public String GetName()
{
return this.name
}
// Same for id
}
我试着检查值是否存在并设置它,但没有任何反应。我抬起头,却找不到答案
if(cb_company.getItemCaption(value) != null)
cb_company.set(value);
谢谢,我试图与名称设置... SMH – Br0thazS0ul
不是为我工作,甚至当我固定的ID为10,例如 – Bourkadi