Package org.patternfly.component.template
package org.patternfly.component.template
Template package serving as a blueprint for creating new PatternFly Java components.
This package contains template classes that demonstrate the required structure, conventions, and patterns for implementing PatternFly components. It is not a functional component — it exists solely as a reference for code generation and consistency.
Package structure
A component package typically contains these classes:
TemplateComponent— The main component class extendingBaseComponent. Contains the static factory method, item management, modifier interfaces, event handlers, and public API.TemplateSubComponent— Abstract base class for all sub-components, extendingSubComponentwith the correctComponentType.TemplateItem— A concrete sub-component with its own factory method, identifier, context data, and event handlers.
Code sections
All component and sub-component classes must organize their code using section markers in this order:
factory— Static factory methodsinstance— Constants, fields, and the constructoradd— Methods to add sub-componentsbuilder— Builder methods returningthisaria— ARIA attribute methodsevents— Event handler registration methodsapi— Public API methods (getters, actions, state changes)internal— Package-private or private helper methods
Usage
Creating a template component with items:
import static org.patternfly.component.template.TemplateComponent.template;
import static org.patternfly.component.template.TemplateItem.templateItem;
template()
.add(templateItem("item-1"))
.add(templateItem("item-2"))
.add(templateItem("item-3"))
.compact()
.onSelect((event, item, selected) -> {});
- See Also:
-
ClassesClassDescriptionThe template component is a template for creating new components.