Chapter 3: Doctrine - The world tree of components

"Know the tree, and you shall know the page." - Wicket Scripture

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

  1. Request arrives and is matched to page/component context.
  2. Target component handles event or action.
  3. Models load/update data.
  4. 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

  • Problem
    Memory usage grows faster than expected and URLs become harder to manage in production.
    Cause
    Pages become stateful unintentionally, often due to AJAX-heavy component design and server-side page instance retention.
    Solution
    Default public pages to stateless mode and explicitly limit where stateful behavior is truly required.
  • Problem
    Crawler traffic causes avoidable load spikes.
    Cause
    Too many stateful URLs are generated and crawlers keep traversing them as distinct pages.
    Solution
    Review robots control and link strategy, and keep publicly crawlable routes mostly stateless.