12. HTML5 Progress - klopfdreh/wicket-components-playground GitHub Wiki
The progress executes a service or any other background process and shows a progress bar in the frontend. #updateProcessValue is executed ever configured duration and returns an incremented integer of the current progress, so the progress bar moves on. The done method is executed if the process has been finished - the max value is reached - the AjaxRequestTarget is given into the method so components can be refreshed / replaced. (done method is not shown in this example)
Java:
Progress progress = new Progress("progress", Duration.seconds(1))
{
private static final long serialVersionUID = 1L;
@Override
protected void initProcess()
{
// Service call is made
}
@Override
public int updateProcessValue()
{
// Checks the state of the service call
// and recalculates the value (the progress moves further on)
int value = getValue() + ((int)(Math.random() * 10));
return value < 200 ? value : 200;
}
};
progress.setMax(200);
add(progress);
HTML:
<progress wicket:id="progress"></progress>