about NativeSelect,plz help me....

			selection.setNullSelectionItemId("");
			selection.setNullSelectionAllowed(false);
			if (dataCacheable != null) {
				List<KeyValuePair> list = dataCacheable.getKeyValueList(fi.getCodeTable());
				list.add(0,new KeyValuePairImpl("", "--choose--"));
				selection.initOptions(list);
			}

but the “–choose–” option does not displayed.
see the code below:


            if (!isNullSelectionAllowed() && id != null
                    && id.equals(getNullSelectionItemId())) {
                // Remove item if it's the null selection item but null
                // selection is not allowed
                continue;
            }

tell me how to …
i wanna display the empty option and null can not be allowed!
btw:create a subclass and override the function AbstractSelect.paintContent?
thanks.

selection.setNullSelectionAllowed(false) hides the null selection option, as you have noticed. I don’t think you can achieve what you want with NativeSelect, but have you tried ComboBox? With that you could put the “–choose–” as the input prompt instead of one of the items.

Anna Koskinen ,thks a lot.
according to the request,we can not use the combox in our project.
in fact, the emtpy option was added to the nativeselect component automaticly,see the js code below:


["location",{
		"name":"genderCode"
	},["8",{
		"id":"PID147","style":"required","type":"native","required":true,"hideErrors":true,"error":["error",{
		},"can not be empty."],"v":{
			"selected":[""]
// look at here,the default value is empty string,so the client engin added the empty option to the nativeselect automaticly?.may i replace the default emtpy option with specified option like "--choose--", and how do it?
		}
	},["options",{
	},["so",{
		"caption":"male","key":"1"
	}],["so",{
		"caption":"female","key":"2"
	}]]]]

The way I understand it, an empty item is added if there is no initial selection, even if you have setNullSelectionAllowed(false), but once you select something that empty item is removed from the list. To my knowledge there is no possible way to leave items visible but not selectable using NativeSelect, or any similar Vaadin component at the moment. Input prompt is what I have used as a workaround, but not every component has it as an option. It’s possible that you might be able to create that functionality yourself by overriding something, but I haven’t tried to do that myself so I can’t say if or how it would work. It might not be anywhere close to trivial.

thks for ur response.
thks.