Hey!
I’ve completed another of my pet components and am here now to share my success to the world! This is a component to enter passcodes that are numerical (PIN codes etc).
I started making this without any real usage purpose, it was more of practice to me on how to create components from scratch, in contrast to adding functionality to existing components. Wanted to still share it if someone would have some usage of it. It can be used for having a very simple login page for sites where security isn’t the most vital part.
You can attach three different listeners to this. The normal Vaadin ValueChangeListener will give you an event every time the user presses send. You can also attach something called CorrectValueListener and WrongValuelListener, which are triggered only when a right or wrong value is entered, respectively. You can yourself decide which of the listeners you want to use (or even attach all if you want to).
Here’s an example of the usage:
Keypad keypad = new Keypad();
layout.addComponent(keypad);
keypad.setPassCode(7348);
keypad.addListener((ValueChangeListener)this);
keypad.addListener((CorrectValueListener)this);
keypad.addListener((WrongValueListener)this);
and an implementation out of the listeners looks like this:
@Override
public void correctValueEntered(ValueEntered event) {
getMainWindow().showNotification("that's correct!");
}