Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    SelectItem can not setDefaultValues

    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);
    		}

    #2
    First, use logging or step-through debugging to determine if you are actually passing valid data to setDefaultValues(). Then, if you think the data is valid, try a similar call by modifying a Showcase sample, and if that reproduces the error, show the modified Showcase code.

    Comment

    Working...
    X