#1
Pagination and audit logs make dashboards more scalable and traceable. Let’s add both features in a Firebird–Spring Boot dashboard easily.

1. Add Dependencies

In your pom.xml:
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
  <groupId>org.firebirdsql.jdbc</groupId>
  <artifactId>jaybird</artifactId>
  <version>5.0.3</version>
</dependency>

2. Firebird Configuration

spring.datasource.url=jdbc:firebirdsql://localhost:3050/D:/data/dashboard.fdb
spring.datasource.username=sysdba
spring.datasource.password=masterkey
spring.jpa.hibernate.ddl-auto=update

3. Define Entities

@Entity
public class User {
    @Id @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    private String username;
    private String role;
}
@Entity
public class AuditLog {
    @Id @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    private String action;
    private String performedBy;
    private LocalDateTime timestamp;
}

4. Create Repositories

public interface UserRepository extends JpaRepository<User, Long> {}
public interface AuditLogRepository extends JpaRepository<AuditLog, Long> {}

5. Implement Pagination and Logging

@Service
public class DashboardService {
    @Autowired private UserRepository userRepo;
    @Autowired private AuditLogRepository logRepo;

    public Page<User> getUsers(int page, int size) {
        return userRepo.findAll(PageRequest.of(page, size));
    }

    public void logAction(String action, String user) {
        AuditLog log = new AuditLog();
        log.setAction(action);
        log.setPerformedBy(user);
        log.setTimestamp(LocalDateTime.now());
        logRepo.save(log);
    }
}

6. Create Controller

@Controller
@RequestMapping("/dashboard")
public class DashboardController {
    @Autowired private DashboardService dashboardService;

    @GetMapping
    public String viewDashboard(@RequestParam(defaultValue = "0") int page, Model model) {
        Page<User> users = dashboardService.getUsers(page, 5);
        model.addAttribute("users", users.getContent());
        model.addAttribute("currentPage", page);
        model.addAttribute("totalPages", users.getTotalPages());
        return "dashboard";
    }

    @PostMapping("/action")
    public String performAction(@RequestParam String username) {
        dashboardService.logAction("Updated role for user", username);
        return "redirect:/dashboard";
    }
}

7. Create HTML Dashboard

dashboard.html
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head><title>Dashboard</title></head>
<body>
<h2>User List</h2>
<table>
<tr><th>Username</th><th>Role</th></tr>
<tr th:each="u : ${users}">
  <td th:text="${u.username}"></td>
  <td th:text="${u.role}"></td>
</tr>
</table>

<div>
  <a th:if="${currentPage > 0}" 
     th:href="@{/dashboard(page=${currentPage - 1})}">Prev</a>
  <span th:text="${currentPage + 1}"></span> /
  <span th:text="${totalPages}"></span>
  <a th:if="${currentPage + 1 < totalPages}" 
     th:href="@{/dashboard(page=${currentPage + 1})}">Next</a>
</div>
</body>
</html>

8. Test the Dashboard

Run the app and visit /dashboard.
You’ll see users displayed with pagination.
Perform an action, and a record will automatically be stored in the AuditLog table for traceability.
#ads

image quote pre code