combo box

Hi ,

How to get the selected value of a combo box .

the code which i wrote always returns the previous value .

Code :

                    com.vaadin.ui.ComboBox cb = new com.vaadin.ui.ComboBox("Select");		
	        cb.setNullSelectionAllowed(false);
                    
                    for(int i = 1;i<=5;i++){

                   cb.addItem(item);
                   cb.setItemCaption(item,"val"+i);

                   }

                   cb.addListener(new Property.ValueChangeListener() { 
		
                   public void valueChange(ValueChangeEvent event) {
        	
        	       System.out.println(event.getProperty().getValue());
        	
                 }
        }); 

What could be the problem ?

Please help.


Regards,
Niyas

Probably it works just fine, but you get the value to your console a bit late and it thus seems to be the previous one. Add cb.setImmediate(true) to get the value sent to server immediately.

Hi Joonas,

Thanks a lot , its working fine .


Regards,
Niyas