Class ProfileController

java.lang.Object
com.example.cab302project.ProfileController

public class ProfileController extends Object
Controller for the User Profile screen (profile-view.fxml). Allows the logged-in user to view and update their personal details including email, phone number, home location, password, and dark mode preference. Changes are validated before being persisted to the database. The screen is accessible to both regular users and police officers. The appropriate hamburger menu variant (HamburgerMenu or PoliceHamburgerMenu) is selected at runtime based on the current user's role from UserSession.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new ProfileController and initialises the DAO from the main application database instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Initialises the screen after the FXML has loaded.
    void
    Validates and saves the user's updated profile information to the database.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ProfileController

      public ProfileController()
      Constructs a new ProfileController and initialises the DAO from the main application database instance.
  • Method Details

    • initialize

      public void initialize()
      Initialises the screen after the FXML has loaded. Loads the current user from the session, populates the form fields, marks the Profile tab active in the nav bar, and wires up the correct hamburger menu variant based on the user's role.
    • onSave

      public void onSave()
      Validates and saves the user's updated profile information to the database. Reads form values, validates email and phone format and coordinate structure, then updates the User object and persists it via the DAO. Displays an appropriate alert for success, validation errors, or database failures.