}
// First time is rendered, select first item
TypeOfWorkHours type = hourCost.getType();
if (hourCost.isNewObject() && type == null) {
Listitem item = lbHoursType.getItemAtIndex(0);
item.setSelected(true);
setHoursType(hourCost, item);
} else {
// If hoursCost has a type, select item with that type
Listitem item = ComponentsFinder.findItemByValue(lbHoursType, type);
if (item != null) {
lbHoursType.selectItem(item);
}
}
lbHoursType.addEventListener(Events.ON_SELECT, new EventListener() {
@Override
public void onEvent(Event event) {
Listitem item = lbHoursType.getSelectedItem();
if (item != null) {
setHoursType((HourCost) row.getValue(), item);
}
}