client.updateVariable(paintableId, "selected",
new String[] { selectedOptionKey }, immediate);
afterUpdateClientVariables();
-
// currentPage = -1; // forget the page
}
public void setSelectedCaption(String selectedCaption) {
explicitSelectedCaption = selectedCaption;
if (selectedCaption != null) {
+ selectedOptionKey = null;
setPromptingOff(selectedCaption);
}
}
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.tests.components.ComponentTestCase;
+import com.vaadin.ui.Button;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.Notification;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
public class ComboBoxScrollingToPageDisabled
extends ComponentTestCase<ComboBox> {
@Override
protected void initializeComponents() {
- ComboBox s = createSelect(null);
+ final ComboBox s = createSelect(null);
s.setScrollToSelectedItem(false);
populate(s, 100);
- Object selection = new ArrayList<Object>(s.getItemIds()).get(50);
+ final Object selection = new ArrayList<Object>(s.getItemIds()).get(50);
s.setValue(selection);
addTestComponent(s);
+
+ Button button = new Button("Select first");
+ button.addClickListener(new ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ s.setValue(s.getItemIds().iterator().next());
+ }
+ });
+ addComponent(button);
+
+ Button button2 = new Button("Select index 50");
+ button2.addClickListener(new ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ s.setValue(selection);
+ }
+ });
+ addComponent(button2);
}
private void populate(ComboBox s, int nr) {
import org.junit.Test;
+import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.LabelElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
import com.vaadin.tests.tb3.newelements.ComboBoxElement;
org.junit.Assert.assertEquals("Item 99", combo.getText());
}
+
+ @Test
+ public void checkUpdateFromServerDisplayedCorrectly() {
+ ButtonElement selFirstButton = $(ButtonElement.class)
+ .caption("Select first").first();
+ ButtonElement sel50Button = $(ButtonElement.class)
+ .caption("Select index 50").first();
+ ComboBoxElement comboBox = $(ComboBoxElement.class).first();
+
+ selFirstButton.click();
+ org.junit.Assert.assertEquals("Item 0", comboBox.getText());
+ sel50Button.click();
+ org.junit.Assert.assertEquals("Item 50", comboBox.getText());
+ selFirstButton.click();
+ org.junit.Assert.assertEquals("Item 0", comboBox.getText());
+ sel50Button.click();
+ org.junit.Assert.assertEquals("Item 50", comboBox.getText());
+ }
}