You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by "reiern70 (via GitHub)" <gi...@apache.org> on 2026/10/01 20:45:43 UTC
[I] Add a generic ProgressBar component to wicket-extensions [wicket]
reiern70 opened a new issue, #1635:
URL: https://github.com/apache/wicket/issues/1635
Wicket has no general-purpose progress bar. UploadProgressBar is tied to file uploads, so applications that need to show the progress of some work (a background job, an import, a multi-step process) each build their own markup and CSS.
This proposes org.apache.wicket.extensions.markup.html.progress.ProgressBar, a small CSS-only component:
- Model: an IModel<? extends Number> holding a percentage. Values are rounded and clamped to 0–100, and null counts as 0.
- Markup: attached to a <div>. It renders a filled part sized to the percentage and a label such as 42%. Existing class attributes on the tag are kept.
- Accessibility: the element gets role="progressbar" with aria-valuemin="0", aria-valuemax="100" and aria-valuenow.
- Styling: the look comes from wicket-progress-bar.css, contributed by the component. It uses the classes wicket-progress-bar, wicket-progress-bar-value and wicket-progress-bar-label, so applications can restyle it. A CSS transition animates width changes.
- Updating: the component re-renders like any other, so target.add(progressBar) in an Ajax or web socket request updates it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@wicket.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Add a generic ProgressBar component to wicket-extensions [wicket]
Posted by Chris Colman via dev <de...@wicket.apache.org>.
On 2/10/2026 6:45 am, reiern70 (via GitHub) wrote:
> reiern70 opened a new issue, #1635:
> URL:https://github.com/apache/wicket/issues/1635
>
> Wicket has no general-purpose progress bar. UploadProgressBar is tied to file uploads, so applications that need to show the progress of some work (a background job, an import, a multi-step process) each build their own markup and CSS.
>
Sounds good!
We've implemented a generic progress bar mechanism for our purposes
which can be invoked at the Java level without a user of the component
having to set up any CSS - it's just a generic Wicket component which
handles everything, including updating of the progress bar whenever the
background process calls methods on an IProgressTracker interface.
It supports a 'phase' as well as a progress % which is often useful for
a long running process that passes through multiple phases. Perhaps
showing an optional 'phase' is something you may consider useful in yours.
The component reuses some existing wicketstuff components to save
reinventing the wheel:
* ModalContentPanel (from org.wicketstuff.modalx) which is displayed
in a ModalWindow via ModalX's
ModalContentPanel.show(AjaxRequestTarget) method
* ProgressBar (from org.wicketstuff.progressbar)
I was going to post the implementation but realized it has dependencies
on some of our own base Panel classes and our BPMN system - maybe I
could refactor it to extract out those dependencies to create a
completely generic Wicket component implementation.
The interface that a background processing thread uses to report
progress to the progress tracker has no dependencies so here it is in
case it's useful to anyone:
/**
* Class Name : IProgressTracker
* Diagram : Event Model
* Project : Utilities
* Type : interface
* Implemented by any class that is responsible for tracking progress
of a process or
* operation.
* The progress is measured on a scale of 0 to 100.
* e.g. tracking the progress of the generation of a report.
*
* During processing calls should be made to updateProgress(int
progress, String message)
* whenever the progress changes significantly or the message changes.
* The 'message' can be anything but typically will be the current
phase of the operation
* and should be displayed in the progress bar with the percentage
completed.
* e.g. Some sample phases for an operation that needs to connect with
another service
* and transfer data to it might be: Initialization, Connecting,
Transferring, Closing
* connection
*
* The process being tracked is only shown as completed after success()
or fail() is
* called.
* Attempts to set the progress above 99 will set it to 99 to prevent
accidentally rounding
* to 100 and showing the user 100% prior to success() or fail() being
called.
* Remember the general rule with progress bars: last 1% always takes
20% of the time
* ;)
*
*/
public abstract
interface IProgressTracker
{
/**
* Returns true if a request to report the process has been issued.
*/
public abstract boolean isAborted();
/**
* Fails the process with the given reason for failure.
*/
public abstract void fail(String reason);
/**
* Call when the process has successfully completed.
*/
public abstract void success();
/**
* Called whenver the progress is updated.
* This should not be called with a value of 100, instead, to indicate
successful completion
* the 'success' method should be called.
*/
public abstract void updateProgress(int progress, String message);
}