With a combobox, once a value is selected the selected value remains in the box. Is there anyway to remove/clear this once it has been selected? i would like to do this so that a user is forced to reselect a value from the list.
If I select “Berlin” and then try to reselect “Berlin” the listner does not pick this up. I have to select a different item from the combo which will then allow me to select “Berlin” again.
I guess there are two things id like to do here:
Clear the selected value in the combo after it has been selected. Which forces the user to use the mouse or type a value.
The current ComboBox implementation does not support detecting re-selection of an already selected item. The client side code actually does send an event about selection to the server in some cases (but not for all methods of selecting an item), but AbstractField.setValue() then ignores the change if the selected item stays the same.
setValue(null) did not work - NullPointerException. I also tried setValue(“”) or with an empty string - no success
The value still persists even if you navigate to different screens and go back to the initial combo
A workaround would be to select another item before the previous item can be reselected. However, imagine the scenario where there is only one item in the combo. The item could never be reselected unless you restart the app (or log out and back in).
Within the valueChange method i tried: myComboName.setValue(null);
stacktrace:
com.vaadin.event.ListenerMethod$MethodException
Cause: com.vaadin.event.ListenerMethod$MethodException
Cause: java.lang.NullPointerException
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:507)
at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:161)
at com.vaadin.ui.AbstractComponent.fireEvent(AbstractComponent.java:1146)
at com.vaadin.ui.AbstractField.fireValueChange(AbstractField.java:884)
at com.vaadin.ui.AbstractField.setValue(AbstractField.java:534)
at com.vaadin.ui.AbstractSelect.setValue(AbstractSelect.java:652)
at com.vaadin.ui.Select.changeVariables(Select.java:420)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariables(AbstractCommunicationManager.java:1087)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(AbstractCommunicationManager.java:587)
at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(CommunicationManager.java:265)
at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:482)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
Caused by: com.vaadin.event.ListenerMethod$MethodException
Cause: java.lang.NullPointerException
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:507)
at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:161)
at com.vaadin.ui.AbstractComponent.fireEvent(AbstractComponent.java:1146)
at com.vaadin.ui.AbstractField.fireValueChange(AbstractField.java:884)
at com.vaadin.ui.AbstractField.setValue(AbstractField.java:534)
at com.vaadin.ui.AbstractSelect.setValue(AbstractSelect.java:652)
at com.vaadin.ui.AbstractSelect.setValue(AbstractSelect.java:621)
at com.example.test.ui.view.UserView$1.valueChange(UserView.java:42)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:487)
... 23 more
Caused by: java.lang.NullPointerException
at com.example.test.ui.view.UserView$1.valueChange(UserView.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:487)
... 35 more