J2EE pattern • Presentation
J2EEPresentationJava example
Application Controller solves a specific structural problem in the design.
Choose commands and views based on application-level navigation rules.
Pattern overview
J2EE pattern
Choose commands and views based on application-level navigation rules.
Intent
Centralize application flow decisions so page navigation and command selection follow explicit rules.
Problem
Screen-to-screen transitions are duplicated across handlers and are hard to change consistently.
Solution
Create a controller that maps request context to actions and resulting views.
Fit and tradeoffs
FamilyJ2EE
CategoryPresentation
Best used when
- When page flow is complex and varies by state, role, or outcome.
Tradeoffs
- Can become a rules dump if not split carefully.
Java example
This example is intentionally compact so the pattern shape stays easy to see.
public final class NavigationController {
public String nextView(CheckoutResult result) {
return result.failed() ? "checkout-error" : "checkout-success";
}
}