Chapter 3: Doctrine - The world tree of components
Component Tree
Every Wicket page is a hierarchy of components. Containers hold children, each node has identity, and each renders to a matching part of HTML. This tree is the core of behavior, visibility, events, and rendering.
HTML/Java Mapping
Wicket binds Java components to markup via wicket:id. A page class and an HTML template form a strict pair. This pairing reduces ambiguity and keeps behavior discoverable by file convention.
WebApplication
WebApplication is your root configuration: mount pages, configure resource settings, and register global behavior. Keep it focused on application-level policy rather than page logic.
Request Cycle
- Request arrives and is matched to page/component context.
- Target component handles event or action.
- Models load/update data.
- Response renders full page or partial AJAX update.
Stateful and Stateless
Stateful pages are ideal for rich forms and user flows. Stateless pages fit cacheable, simple views. Use stateless mode where practical, but do not fear state when it improves clarity.
Practical Pitfalls
-
ProblemMemory usage grows faster than expected and URLs become harder to manage in production.CausePages become stateful unintentionally, often due to AJAX-heavy component design and server-side page instance retention.SolutionDefault public pages to stateless mode and explicitly limit where stateful behavior is truly required.
-
ProblemCrawler traffic causes avoidable load spikes.CauseToo many stateful URLs are generated and crawlers keep traversing them as distinct pages.SolutionReview robots control and link strategy, and keep publicly crawlable routes mostly stateless.