PatternFly Java 0.4.11 API
PatternFly Java
PatternFly Java is a 💯 Java implementation of PatternFly without any JavaScript dependencies (except for charts).PatternFly Java's Its goal is to provide an easy-to-use, elegant, and efficient API to build complex web applications with PatternFly in Java. PatternFly Java integrates with and builds upon Elemento's builder API. It works with both GWT and J2CL.
API Design
PatternFly Java integrates with and builds upon Elemento's builder API. Static factory methods are used to create the components, and public instance methods add child elements and modify the component.
Static Factory Methods
These methods are used to create a component. They are usually named after the component, are overloaded to accept required and optional arguments, and return an instance of the newly created component:
Button button1 = button("Click me!");
Button button2 = button("PatternFly", "https://www.patternfly.org");
Add Methods
These methods add subcomponents to a main component. They are usually called add<SubComponent>()
and return the main component so that the method call can be chained with other methods:
Dropdown dropdown = dropdown()
.addToggle(menuToggle("Dropdown"))
.addMenu(menu()
.addContent(menuContent()
.addList(menuList()
.addItem(actionMenuItem("item-0", "Action")))));
Builder / Modifier Methods
These methods modify the current component. They return the current component so that the method call can be chained with other methods:
Card card = card()
.flat()
.rounded()
.large();
ARIA-Related Methods
These methods set ARIA-related attributes in the component. They're usually named aria<Attribute>()
and return the component so that the method call can be chained with other methods:
Navigation navigation = navigation(flat)
.ariaScrollBackLabel("� back")
.ariaScrollForwardLabel("� forward");
Event Handlers
These methods add event handlers for various events to the component. They are usually named
on<Event>(), accept an event handler, and return the component so that the method call can be
chained with other methods. PatternFly Java defines some
common event handlers that are reused in all components.
Drawer drawer = drawer().id("drw")
.onToggle((e, c, expanded) -> console.log("Drawer expanded: " + expanded));
Common Interfaces
Common behavior across all components is implemented by base classes and interfaces. All components extend from
either BaseComponent or BaseComponentSVG. These
base classes implement interfaces from Elemento to manipulate the component element.
In addition, components implement these interfaces to provide a common API:
-
ModifiersThe sub-interfaces defined in this 'umbrella' interface are used to toggle one specific flag of a component. For example,card().plain()toggles theplainflag of the card component and is defined in theModifiers.Plaininterface. -
CloseableImplemented by components that provide some kind of popup that can be closed. -
ComponentContext,HasIdentifier, andHasItemsThese interfaces are often implemented by components that have a parent-child relationship. -
ComponentIconandComponentIconAndTextThese interfaces are implemented by components that provide text resp. an icon and a text. -
ComponentProgressImplemented by components that provide some kind of progress. -
ExpandableImplemented by components that provide some kind of expandable content. -
HasValueandHasObservableValueThese interfaces are implemented by components that provide a value or an observable value.
Modules
PatternFly Java consists of these Maven modules (a-z):

| Module | Description |
|---|---|
| patternfly-java-bom | Bill of materials |
| patternfly-java-codeeditor | PatternFly codeeditor |
| patternfly-java-components | PatternFly components |
| patternfly-java-core | Core PatternFly Java classes |
| patternfly-java-finder | PatternFly Java Finder extension |
| patternfly-java-gwt | PatternFly Java for GWT |
| patternfly-java-icons | PatternFly Java icons |
| patternfly-java-j2cl | PatternFly Java for J2CL |
| patternfly-java-layouts | PatternFly Java layouts |