Exercise: Build a login dialog
A possible solution is at the end of this page.
Write a Login Dialog in BBj. The Dialog should have two buttons - "Login" and "Cancel," a field for a user name and one for a password. It should be encapsulated in a BBj class and check for a correct username/password pair. You can hardcode one or two combinations in this task.
The Dialog should return a Boolean TRUE if the username and password are accepted, and FALSE if the login procedure was canceled. When the user tries to enter an invalid username/password combination, an error message should appear like "Please check your input" and the dialog should remain open.
Possible solution
The original course had no solution for this exercise, so this one was written for this book. Log in with the user name demo and the password bbj-demo. These demo credentials sit in the code only for this exercise, and a real app checks a user store instead. show() returns BBjAPI.TRUE after a correct login and BBjAPI.FALSE after Cancel, and a wrong pair shows "Please check your input" while the dialog stays open. The dialog uses plain controls without CSS and also runs in the DWC. The solution is in LoginDialog.bbj, and you find all files in the exercises.zip link.