I use SelectItem for multiselection in a DynamicForm. I can save data to DB normally. But when I get data from service, I can not successfully setDefaultValues. The code is attached, please advice.
Code:
final DynamicForm form3; { form3 = new DynamicForm(); vm.addMember(form3); form3.setNumCols(2); DataSource targetsItemDS = DataSource.get("apPositionDMI"); SelectItem bulletinTargetsItem = new SelectItem(); bulletinTargetsItem.setOptionDataSource(targetsItemDS); bulletinTargetsItem.setDisplayField("boPositionKey"); bulletinTargetsItem.setValueField("id"); bulletinTargetsItem.setMultiple(true); bulletinTargetsItem.setTitle(i18n.bulletinTargets()); bulletinTargetsItem.setName("positionList"); bulletinTargetsItem.setShowTitle(true); bulletinTargetsItem.setTitleAlign(Alignment.LEFT); // bulletinTargetsItem.setHint("<nobr>(multi -select, pick list)</nobr>"); if (record != null) { String postitionIds = record.getAttribute("postitionIds"); if (postitionIds != null && postitionIds.length() > 0) { bulletinTargetsItem.setDefaultValues(postitionIds.split(",")); } } form3.setColWidths(leftWidth, "*"); form3.setFields(bulletinTargetsItem); formLayout.addMember(form3); }
Comment