0

I have got a Vaadin Combobox (Vaadin 8) to which I add two items. I would like that ComboBox to propose all views to which the user is supposed to navigate by a Vaadin NativeButton as described in the code snippet. In spite of the fact that "ContactView" is proposed below the ComboBox as soon as I type a "C", I cannot select "ResourceView" - and yet I have added it to theComboBox. What did I get wrong so that there is no correct dropdown?

        navigatorCombobox = new ComboBox<String>("Navigate to...");
        
        navigatorCombobox.setItems(Arrays.asList("ContactView", "ResourceView")); 
        
        navigatorButton = new NativeButton("go");
        
        navigatorButton.addClickListener(
                event -> { 
                    if(StringUtils.isNotEmpty(navigatorCombobox.getValue()) && navigatorCombobox.getValue().equals("ContactView")) {

                    getUI().getNavigator().navigateTo(MynavigatorUI.CONTACTVIEW);
                    
                 } else if (StringUtils.isNotEmpty(navigatorCombobox.getValue()) && navigatorCombobox.getValue().equals("ResourceView")) {

                        getUI().getNavigator().navigateTo(MynavigatorUI.RESOURCEVIEW);

                        }
        }); 


4

1 回答 1

0

这是预期的行为。在字段中键入“C”后,ComboBox 会将可选选项限制为以“C”开头的选项。

于 2021-07-26T14:29:58.080 回答