When handling every request directly means parsing parameters and coordinating behavior yourself, a component-based framework offers a higher-level approach: reusable UI components provide behavior, while the framework manages their interaction with browser requests. section 5.4 section 5.4.1
A typical component-based application divides responsibilities among:
- UI components, implemented as regular Java classes, that provide behavior and follow a framework-managed component life cycle. section 5.4.1
- HTML templates that lay out the components, plus configuration that maps components to placeholders, resources, and client-generated events. section 5.4.1
- The framework, which connects browser requests and events to component instances and their methods. section 5.4.1
Because a component is often ordinary Java code, testing it can resemble testing other Java classes. Templates and framework wiring add separate concerns; some frameworks use XML configuration, while others use Java annotations. section 5.4.1 section 5.4.1
Framework examples
Apache Tapestry, Wicket, and JavaServer Faces (JSF) are examples of component-based frameworks. Wicket represents pages as Java classes, with HTML templates as the remaining non-Java artifacts apart from web.xml. section 5.4 section 5.4.1
