J2EE pattern • Presentation
J2EEPresentationJava example
Composite View solves a specific structural problem in the design.
Assemble a page from reusable view fragments.
Pattern overview
J2EE pattern
Assemble a page from reusable view fragments.
Intent
Create a page from modular reusable subviews so layout and page composition remain consistent.
Problem
Large pages repeat the same headers, navigation, summary blocks, and widgets.
Solution
Break the page into reusable fragments that a composing view assembles.
Fit and tradeoffs
FamilyJ2EE
CategoryPresentation
Best used when
- For dashboards, admin screens, and shared layout systems.
Tradeoffs
- Too much fragmentation can make page flow harder to trace.
Java example
This example is intentionally compact so the pattern shape stays easy to see.
public record DashboardViewModel(UserSummary summary, List<Activity> activities, List<Alert> alerts) {}
// Controller prepares a single model; JSP/Thymeleaf includes reusable fragments
// like header, summary-card, activity-list, and alert-banner.