简体   繁体   中英

Referencing data in Vaadin Combobox?

I've been having trouble mapping data to a combobox in vaadin. My intention was to have a few comboboxes in a window and a button that the user can press when he is done making selections in the comboboxes.

I want to add a listener to the button, and I know that it is easy to do, but then when the "buttonPressed", or whatever its called, runs I would like it to do something like this(pseudocode):

ComboBox c1;
ComboBox c2;
Button b = new Button(new Button.ClickListener(){
    public void buttonPressed(Event e){
        dostuff(c1.getSelected(), c2.getSelected));
    }
});

Is this possible or am I missing something? Sorry if I sound stupid but I have googled and the examples are to advanced for me and omits stuff that I need to see.

Yes, your pseudo code should work fine; I can't see any problems with what you are doing here. Mind you, you haven't actually said what the problem actually is...

BTW: a ComboBox is called a Select in Vaadin, and getSelected is getValue - ie the value of a Select is the selected item.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM