33import java .io .IOException ;
44
55import com .model .AuthenticationService ;
6+
67import javafx .fxml .FXML ;
78import javafx .scene .control .Label ;
89import javafx .scene .control .TextField ;
910import javafx .scene .input .MouseEvent ;
1011
1112/**
1213 * Controller for register.fxml
14+ * Handles user registration by validating form inputs and
15+ * calling {@link AuthenticationService#register(String, String, String, String, String)}.
16+ * Navigates to the login screen on success or shows an error message on failure.
1317 */
1418public class RegisterController {
1519
@@ -26,7 +30,14 @@ public class RegisterController {
2630 private Label lbl_error ;
2731
2832 private final AuthenticationService authService = new AuthenticationService ();
29-
33+ /**
34+ * Handles the Register button click event.
35+ * Validates that all required fields are filled, attempts to register
36+ * the user, and navigates to the login screen if successful. Displays
37+ * an error message otherwise.
38+ * @param event the mouse event triggered by the button click
39+ * @throws IOException if navigation to another scene fails
40+ */
3041 @ FXML
3142 private void btnRegisterClicked (MouseEvent event ) throws IOException {
3243 String userId = txt_userId .getText ();
@@ -58,7 +69,12 @@ private void btnRegisterClicked(MouseEvent event) throws IOException {
5869 lbl_error .setVisible (true );
5970 }
6071 }
61-
72+ /**
73+ * Handles the Back button click event.
74+ * Navigates back to the home screen.
75+ * @param event the mouse event triggered by the button click
76+ * @throws IOException if navigation fails
77+ */
6278 @ FXML
6379 private void back (MouseEvent event ) throws IOException {
6480 App .setRoot ("home" );
0 commit comments