Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Filling A TextField - An Event Listener?
Into some fields, we will be populating the TextField values from a bar-code scanner.
These scanners put out fixed size pieces of data.
The Use Case? When a field is filled in with data from a bar-code scanner, the program should move the focus field to the next field in the tab order, so that the User does not have to hit the 'Tab' key to move to the next field.
I'm curious what 'event listener' I can attach to a field that fires while that field still has focus?
Or, what 'event listener' that can fire so I can see how size of the value in the Text Field.
Hi gunnars, I've got some experience with bar-code scanners like 5 years ago, so the situation might changed already. So it is just a suggestion / wild guess.
You can specify to send a carriage return as a last symbol ( in some models you can specify to send any not-a-number symbol as a last one).Their should be some kind of utilty/ driver for the scanner. So you can specify to send the tab symbol as a last symbol, and try it out. By default carriage return(code #13) should be last symbol. Then other options can be play around with either valueChangeListener and textChangeListener.
In textChangeListener you can check if it's last symbol (equals to "#13" for example), and then focus to other element. Go throught textChangeListener javadoc, it has a pause parameter meaning it wont send the request to the server side on every symbol, so in your case it will send only once (probably). Same approach could be used with valueChange Listener, but I'll recommend to use textChangeListener, because valueChange listener is triggered only when the element changes the focus if I remember correctly.
I can't give you a complete solution or example, because don't have any bar-code scanner around :)
Yes, the bar-code scanner does do this. Perfect.