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 extending BaseComponent. Contains the static factory method, item management, modifier interfaces, event handlers, and public API.
  • TemplateSubComponent — Abstract base class for all sub-components, extending SubComponent with the correct ComponentType.
  • 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:

  1. factory — Static factory methods
  2. instance — Constants, fields, and the constructor
  3. add — Methods to add sub-components
  4. builder — Builder methods returning this
  5. aria — ARIA attribute methods
  6. events — Event handler registration methods
  7. api — Public API methods (getters, actions, state changes)
  8. 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:
  • Classes
    Class
    Description
    The template component is a template for creating new components.
    A selectable item within a
    invalid reference
    Template
    component.