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);

}

Reply via email to