Problem with Double NativeSelect

Hi all,

I try to implement two NativeSelect lists which are linked together like in the Book example Field interaction but the second list is not filled when i select one value in the first list.

With the Eclipse debugger, items are well added in the second select list
Could you tell me what is wrong in the code below ?

Thanks

final NativeSelect site = new NativeSelect(“Site”);
final NativeSelect op = new NativeSelect(“Opérateur”);

//First select list
if (pid.equals(“nomSite”)) {

		site.setRequired(true);
		site.setRequiredError("Le site n'est pas renseigné");
		for (Site s : new SiteDAO().findAll()) {
			site.addItem(s);
			site.setItemCaption(s,s.getNom());
		}
		site.setNullSelectionAllowed(false);
		site.setImmediate(true);
		
		site.addListener(new Property.ValueChangeListener() {
                public void valueChange(ValueChangeEvent event) {
            	
                        Site selected = (Site) site.getValue();
                
                       if (selected == null) return;
                	
                	op.setRequired(true);
                	op.setRequiredError("L'opérateur n'est pas renseigné");
        			op.setNullSelectionAllowed(false);
                	
                	for (Operation o : new OperationDAO().findBySite(selected.getId())) {
                		op.addItem(o.getOperateur());
                	}
                	op.setEnabled(true);	              
                }
               });			
		return site;
	}
            //second select list
	else if (pid.equals("operateur")) {
		op.setEnabled(false); //Select a site first
		op.setImmediate(true);
		return op;
	}

Well, if the items seem to get added, but are not visible:
Which itemCaptionMode are you using? I you’re using the default, does whatever o.getOperateur() is returning have a toString() that actually returns something other than the empty string?

This is just a guess, of course…

Best Regards,
Marc

OK, the problem is solved