This document explains the development workflow for the PatternFly Java Showcase application, which demonstrates all components, layouts, and charts in the library. It covers the dual-build system architecture (J2CL + Parcel), the Express development server, hot reload behavior, and debugging strategies.
For information about the showcase's deployment and publishing process, see Release Process. For general repository setup instructions, see Local Development Setup.
The showcase uses a hybrid development architecture that separates Java compilation from frontend asset bundling, then unifies them through an Express proxy server.
Sources: showcase/README.md5-31 showcase/package.json11-16 showcase/server.js1-64
The development mode requires two terminal sessions running simultaneously.
Start the J2CL watch process from the repository root:
This command activates the showcase Maven profile and runs J2CL's incremental compilation mode. Wait for the message:
[INFO] ----- Build Complete: ready for browser refresh -----
The J2CL plugin monitors Java source files under showcase/src/main/java and transpiles them to JavaScript in target/showcase/showcase.js Each compilation produces multiple bundle files (e.g., bundle_0.js, bundle_1.js) containing the transpiled Java code and dependencies.
From the showcase directory, start the frontend build system:
This executes three concurrent processes defined in showcase/package.json15:
start:parcel): Monitors showcase/src/web/dev.html and bundles frontend assets on port 1235start:server): Runs showcase/server.js on port 1234 to unify J2CL and Parcel outputsopen:browser): Opens http://localhost:1234 when the server is readySources: showcase/README.md11-30 showcase/package.json11-15 showcase/pom.xml
The showcase exhibits different reload behaviors depending on which files are modified:
| File Type | Build System | Reload Behavior | Latency |
|---|---|---|---|
Java files (.java) | J2CL Maven Plugin | Manual browser refresh required | 2-5 seconds |
HTML files (.html) | Parcel | Automatic hot module replacement | < 1 second |
CSS files (.css) | Parcel | Automatic hot module replacement | < 1 second |
JavaScript files (.js) | Parcel | Automatic hot module replacement | < 1 second |
| Chart components | J2CL + Parcel | Manual refresh for Java changes, auto for CSS | Varies |
J2CL's watch mode detects changes and recompiles incrementally, but it has no mechanism to notify the browser of completed builds. The Express server serves static J2CL output files, so the browser must be manually refreshed to load the updated JavaScript.
Parcel, by contrast, uses WebSocket connections for hot module replacement (HMR), enabling automatic browser updates when frontend assets change.
Sources: showcase/README.md8-9 showcase/server.js38-53
The Express server in showcase/server.js acts as a reverse proxy and static file server, unifying J2CL's compiled JavaScript with Parcel's bundled assets.
The server implements five routing strategies as defined in showcase/server.js24-58:
/parcel-assets/*): Proxies requests to Parcel's dev server on port 1235, enabling HMR WebSocket connections/showcase.js): Serves the main transpiled entry point from target/showcase/showcase.js/bundle*.js): Serves code-split bundles generated by J2CL/sources/*): Serves Java source files for debugging (source map support)target/showcase//*): Returns dev.html for client-side routing via PlaceManagerSources: showcase/server.js16-63
The Java application initializes in showcase/src/main/java/org/patternfly/showcase/Showcase.java:
Key initialization steps in Showcase.java77-142:
#/id(MAIN_ID) as the content container, sets page title pattern, and registers annotated placesSources: showcase/src/main/java/org/patternfly/showcase/Showcase.java66-156
The frontend entry point showcase/src/web/main.js1-28 imports PatternFly CSS and chart web components:
| Import | Purpose |
|---|---|
@patternfly/patternfly/patternfly.css | Core PatternFly styles |
@patternfly/patternfly/patternfly-addons.css | Additional component styles |
@patternfly/patternfly/patternfly-charts.css | Chart-specific styles |
@patternfly-java/charts/dist/charts | Chart web component definitions |
./pforg/*.css | PatternFly.org documentation styles |
./showcase.css | Custom showcase styles |
@github/relative-time-element | Time formatting web component |
highlight.js/lib/common | Syntax highlighting library |
The hljs object is exported to the global window scope (main.js27) so J2CL-compiled code can access it for code snippet highlighting.
Sources: showcase/src/web/main.js1-28
Charts in the showcase use web components that wrap React chart libraries. This integration requires coordination between J2CL, NPM packages, and Parcel bundling.
The externs file charts/src/main/resources/META-INF/externs/charts.externs.js prevents J2CL's compiler from mangling chart property names. It declares types for:
DonutElement, BulletElement, ChartElement (charts.externs.js29-130)Data, BulletData, LegendData, Threshold (charts.externs.js133-198)LabelsFn for custom label formatting (charts.externs.js203-204)These declarations ensure that when Java code sets properties like element.data = ..., the JavaScript output preserves the exact property name data instead of renaming it to something like a during optimization.
Sources: charts/src/main/resources/META-INF/externs/charts.externs.js1-205 charts/npm/src/react-wrapper.js71-393
Showcase pages for components follow a consistent structure:
Component pages implement the Place interface and use the @Place annotation for routing. The showcase/code.java JBang script extracts code snippets from special comment markers:
The script generates showcase/src/main/java/org/patternfly/showcase/Code.java with a snippets map, allowing pages to display source code alongside live examples.
Sources: showcase/code.java1-191
The production build process differs significantly from development mode:
Key differences from development mode:
| Aspect | Development | Production |
|---|---|---|
| J2CL Mode | Incremental watch | Single full compilation |
| Parcel Entry | dev.html | index.html (package.json9) |
| Express Server | Yes, with proxy | No, direct http-server |
| Minification | Disabled | Enabled |
| Source Maps | Full | Optional/minimal |
| Port | 1234 | 8080 |
Sources: showcase/README.md32-42 showcase/package.json16-17 showcase/pom.xml
Place@Place(route = "/components/my-component", title = "My Component")// @code-start:snippet-id and // @code-end:snippet-id commentsmvn j2cl:watch -P showcase)J2CL generates source maps that map JavaScript back to Java. To debug:
sources folder containing Java filesSource map files are served by the Express server's route handler at showcase/server.js50-53
Charts are React components wrapped in Lit web components. To debug:
<pfj-chart-*> elementelement.data, element.width, etc.The React wrapper's lifecycle is managed by ReactWrapperElement in charts/npm/src/react-wrapper.js71-393
To update the PatternFly CSS dependency:
@patternfly/patternfly versionnpm install in the showcase directorynpm run watchTo test the production build before deployment:
mvn clean package -P showcase,prodcd showcase && mvn com.github.eirslett:frontend-maven-plugin:npm@http-serverhttps://localhost:8080 (note HTTPS due to --ssl flag)The production build uses showcase/cert.pem for local HTTPS testing.
Sources: showcase/README.md1-43 showcase/package.json1-42 showcase/server.js1-64
Refresh this wiki