| [ Web Proxy ] |
| Viewing: https://deepwiki.com/patternfly-java/patternfly-java/5.7-wizard-component | [Back] [Original] |
The Wizard component provides a guided multi-step workflow for completing tasks or creating objects through a series of sequential steps. This document covers the Wizard class and its sub-components (WizardStep, WizardNav, WizardFooter, WizardHeader), navigation patterns (progressive, visit-required), step lifecycle handlers, validation mechanisms, and modal integration.
For information about Form components used within wizard steps, see 5.1. For Modal components that can contain wizards, see 5.4.
The Wizard component follows a composite pattern where Wizard acts as the main container managing a linked list of WizardStep items. Each step can contain arbitrary content and define handlers to control navigation flow.
Sources: components/src/main/java/org/patternfly/component/wizard/Wizard.java64-114 components/src/main/java/org/patternfly/component/wizard/WizardStep.java46-94 components/src/main/java/org/patternfly/component/wizard/WizardFooter.java35-70
The Wizard class extends BaseComponent<HTMLElement, Wizard> and implements HasItems<HTMLElement, Wizard, WizardStep> to manage step collections.
Key Fields:
Map<String, WizardStep> items - All steps indexed by identifierWizardStep head, current, tail - Linked list pointersWizardNav nav - Navigation sidebarWizardFooter footer - Button containerWizardContext context - Shared data storageboolean progressive - Progressive step visibility modeboolean visitRequired - Disables unvisited stepsPrimary Methods:
| Method | Description |
|---|---|
addItem(WizardStep) | Adds a step to the wizard, updates linked list and nav |
select(String|WizardStep) | Navigates to a specific step |
next() | Navigates to next enabled step |
previous() | Navigates to previous enabled step |
cancel() | Fires cancel handlers |
currentStep() | Returns current active step |
context() | Returns shared context for data storage |
Sources: components/src/main/java/org/patternfly/component/wizard/Wizard.java64-508
The WizardStep class represents an individual step in the wizard workflow. It implements HasIdentifier, Disabled, ComponentContext, and ElementContainerDelegate.
Key Fields:
String identifier - Unique step identifierString title - Display titleWizardStepType type - Step type (step, review, progress, summary)HTMLElement bodyElement - Container for step contentWizardStep previous, next - Linked list pointersboolean disabled, visited - State flagsValidationStatus status - Success, warning, or error indicatorHandler Fields:
WizardStepNextHandler nextHandler / WizardStepNextPromise nextPromiseWizardStepPreviousHandler previousHandler / WizardStepPreviousPromise previousPromiseWizardStepEnterHandler enterHandlerWizardStepLeaveHandler leaveHandlerSources: components/src/main/java/org/patternfly/component/wizard/WizardStep.java46-296
The WizardNav contains a list of WizardNavItem instances that represent clickable step links in the sidebar.
WizardNavItem includes:
WizardStep.identifierWizard.select(identifier)Sources: components/src/main/java/org/patternfly/component/wizard/WizardNavItem.java52-181
The WizardFooter contains three buttons managed by the wizard:
| Button | Variable | Default Text | Behavior |
|---|---|---|---|
| Back | backButton | "Back" | Calls Wizard.previous() |
| Next | nextButton | "Next" / "Finish" | Calls Wizard.next() |
| Cancel | cancelButton | "Cancel" | Calls Wizard.cancel() |
The footer automatically updates button states and labels based on current step position and type.
Sources: components/src/main/java/org/patternfly/component/wizard/WizardFooter.java35-127
Optional header component containing:
WizardHeaderTitle - Title text/elementWizardHeaderDescription - Description paragraphSources: components/src/main/java/org/patternfly/component/wizard/WizardHeaderDescription.java27-54
The WizardContext provides a shared data store accessible from all steps. Each step also has its own ComponentContext for step-local data.
Usage Pattern:
// Store data in step's onLeave handler
step.onLeave((wzd, step) -> wzd.context().store("age", ageInput.value()));
// Retrieve data in next step's onEnter handler
step.onEnter((wzd, step) -> ageOutput.text(wzd.context().get("age", "n/a")));
Sources: showcase/src/main/java/org/patternfly/showcase/component/WizardComponent.java274-281
The WizardStepType enum defines four step types:
| Type | Purpose | Navigation Behavior |
|---|---|---|
step | Standard step | Shows in nav, enables Next button |
review | Review/confirmation | Shows in nav, changes Next to "Finish" |
progress | Loading/processing | Not shown in nav, adds "finished" modifier |
summary | Completion message | Not shown in nav, adds "finished" modifier |
Sources: components/src/main/java/org/patternfly/component/wizard/Wizard.java44-47
Standard Mode:
Progressive Mode (wizard.progressive()):
Visit Required Mode (wizard.visitRequired()):
Sources: components/src/main/java/org/patternfly/component/wizard/Wizard.java170-195 showcase/src/main/java/org/patternfly/showcase/component/WizardComponent.java173-190
Sources: components/src/main/java/org/patternfly/component/wizard/Wizard.java326-463
| Method | Triggered By | Calls | Purpose |
|---|---|---|---|
previous() | Back button | navigateBack(previousEnabledStep) | Navigate to previous step |
next() | Next button | navigateForward(nextEnabledStep) or finish() | Navigate forward or finish |
select(step) | Nav item click | navigateBack() or navigateForward() | Jump to specific step |
navigateBack(step) | Internal | previousHandler / previousPromise navigateTo() | Execute previous validation |
navigateForward(step) | Internal | forwardThen(() -> navigateTo()) | Execute next validation |
forwardThen(callback) | Internal | nextHandler / nextPromise callback | Validate then execute callback |
navigateTo(step) | Internal | leaveHandler update state enterHandler stepChangeHandlers | Perform actual navigation |
Sources: components/src/main/java/org/patternfly/component/wizard/Wizard.java326-463
Sources: components/src/main/java/org/patternfly/component/wizard/WizardStep.java135-216
From the showcase's "Form validation" example, steps use handlers to validate input:
Setup Pattern:
BiConsumer<TextInput, String>step.nextIf(handler)onLeave handlerCode Flow:
WizardStep.nextIf(handler)
User clicks Next
WizardFooter.nextButton onClick
Wizard.next()
Wizard.navigateForward(nextStep)
Wizard.forwardThen(callback)
current.nextHandler.onNext(wizard, current, next)
returns boolean (validation result)
if true: callback.call() navigateTo(nextStep)
if false: stay on current step
Sources: showcase/src/main/java/org/patternfly/showcase/component/WizardComponent.java243-283 components/src/main/java/org/patternfly/component/wizard/Wizard.java405-424
The showcase's "Handlers and promises" example demonstrates promise usage for simulated cooking workflow:
Promise Pattern:
WizardStepNextPromise that returns Promise<Boolean>footer.disableButtons()setInterval for progress simulation)finally_() re-enables buttons via footer.updateButtons()Sources: showcase/src/main/java/org/patternfly/showcase/component/WizardComponent.java452-470
Steps can display visual status indicators in the navigation:
Status changes update both the step and its corresponding WizardNavItem, adding status icons and CSS modifiers.
Sources: components/src/main/java/org/patternfly/component/wizard/WizardStep.java250-260 showcase/src/main/java/org/patternfly/showcase/component/WizardComponent.java325-353
Each step can override default button labels:
The WizardFooter.updateButtons() method checks current.customButtonNames map and applies overrides.
Sources: components/src/main/java/org/patternfly/component/wizard/WizardStep.java111-114 components/src/main/java/org/patternfly/component/wizard/WizardFooter.java101-126
The Modal class provides first-class wizard support via the addWizard(Wizard) method.
Modal-Wizard Integration Pattern:
Automatic Behaviors:
hideClose = true)modal.close()modal.close()Sources: components/src/main/java/org/patternfly/component/modal/Modal.java228-238 showcase/src/main/java/org/patternfly/showcase/component/WizardComponent.java305-323
Sources: components/src/main/java/org/patternfly/component/wizard/Wizard.java326-463
Sources: showcase/src/main/java/org/patternfly/showcase/component/WizardComponent.java136-152
Sources: showcase/src/main/java/org/patternfly/showcase/component/WizardComponent.java192-241
Sources: showcase/src/main/java/org/patternfly/showcase/component/WizardComponent.java243-283
The wizard maintains a doubly-linked list of steps using WizardStep.previous and WizardStep.next fields. This enables efficient sequential navigation without array indexing.
head step1 step2 step3 tail
current
Sources: components/src/main/java/org/patternfly/component/wizard/Wizard.java86-89 components/src/main/java/org/patternfly/component/wizard/WizardStep.java76-77
Sub-components (WizardStep, WizardNavItem, WizardFooter) use lookupComponent() to find their parent Wizard instance. This is enabled by Wizard.storeComponent() in the constructor.
Sources: components/src/main/java/org/patternfly/component/wizard/Wizard.java113 components/src/main/java/org/patternfly/component/wizard/WizardStep.java283-295
In progressive mode, nav items are dynamically added/removed during navigation:
Sources: components/src/main/java/org/patternfly/component/wizard/Wizard.java429-444
The WizardFooter.updateButtons() method implements button state logic:
| Condition | Back Button | Next Button | Next Text |
|---|---|---|---|
current == head | Disabled | Enabled | Custom or "Next" |
current == tail or type == review | Enabled | Enabled | Custom or "Finish" |
| Middle step | Enabled | Enabled | Custom or "Next" |
Sources: components/src/main/java/org/patternfly/component/wizard/WizardFooter.java101-126
Core Classes:
Handler Interfaces:
Examples:
Modal Integration:
Refresh this wiki
Enter email to refresh| Web Proxy Viewer | New URL | Original Page |