public class ProgressBar
extends org.apache.wicket.markup.html.panel.Panel
implements org.apache.wicket.markup.html.IHeaderContributor
The ProgressBar
component displays a horizontal progress bar
that is updatable via AJAX and displays the progress of some task. The
current progress is given with a Progression
value object.
This is a small example of a static ProgressBar
without AJAX
updates:
final ProgressBar bar;
add(bar = new ProgressBar("progress", new ProgressionModel() {
protected Progression getProgression() {
// progress is an int instance variable defined somewhere else
return new Progression(progress);
}
}));
If the model for getting the Progression
is not known at the
time of construction, it could be injected later.
The progress bar can be used both actively or passively (e.g. to show progress in a wizard). The active progress bar must be started from within an ajax request (e.g. AjaxButton), as shown below:
form.add(new AjaxButton("button") {
protected void onSubmit(AjaxRequestTarget target, Form form) {
bar.start(target);
// start some task
}
}
The ProgressBar
is automatically stopped (including AJAX
updates) when the isDone()
method of the Progress
object returns true. The bar can be stopped anytime using the
stop()
method.
Constructor and Description |
---|
ProgressBar(String id,
ProgressionModel model) |
Modifier and Type | Method and Description |
---|---|
protected org.apache.wicket.model.AbstractReadOnlyModel<String> |
getLabelModel(ProgressionModel model)
Create the model for the label on the bar.
|
protected org.apache.wicket.model.IModel<String> |
getMessageModel(ProgressionModel model)
Create the model for the message label on the bar.
|
org.apache.wicket.util.time.Duration |
getRefreshDuration() |
protected void |
onFinished(org.apache.wicket.ajax.AjaxRequestTarget target)
Override this method for custom action on finish of the task when
progression.isDone()
This could be cleaning up or hiding the ProgressBar for example.
|
protected void |
onInitialize() |
void |
renderHead(org.apache.wicket.markup.html.IHeaderResponse response) |
void |
reset()
Allow overriding components to define some reset mechanism when the bar is going to be re-used
|
void |
setRefreshDuration(org.apache.wicket.util.time.Duration refreshDuration) |
void |
start(org.apache.wicket.ajax.AjaxRequestTarget target)
Start the progress bar.
|
protected void |
update(Progression progression,
org.apache.wicket.ajax.AjaxRequestTarget target)
This will keep getting polled till
Progression.isDone() is true, even if main thread that calls the class terminates
the ajax thread will keep polling this (via DynamicAjaxSelfUpdatingTimerBehavior .onPostProcessTarget() |
onComponentTag, onComponentTagBody, renderHead
newHeaderPartContainer, renderHeadFromAssociatedMarkupFile
getMarkupType, getWebPage, getWebRequest
add, addOrReplace, autoAdd, autoAdd, contains, findMarkupStream, get, get, getAssociatedMarkupStream, getMarkupStream, hasAssociatedMarkup, internalAdd, isTransparentResolver, iterator, iterator, newMarkupResourceStream, onRender, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderComponentTagBody, renderNext, replace, setDefaultModel, setMarkupStream, size, swap, toString, toString, visitChildren, visitChildren
add, addStateChange, afterRender, beforeRender, callOnBeforeRenderIfNotVisible, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, configure, continueToOriginalDestination, debug, detach, detachBehaviors, detachModel, detachModels, determineVisibility, error, exceptionMessage, fatal, findPage, findParent, findParentWithAssociatedMarkup, getApplication, getBehaviors, getBehaviors, getBehaviorsRawList, getClassRelativePath, getComponentBorder, getConverter, getConverter, getDefaultModel, getDefaultModelObject, getDefaultModelObjectAsString, getDefaultModelObjectAsString, getEscapeModelStrings, getFeedbackMessage, getFlag, getFlag, getId, getInnermostModel, getInnermostModel, getLocale, getLocalizer, getMarkupAttributes, getMarkupId, getMarkupId, getMarkupIdImpl, getMetaData, getModelComparator, getOutputMarkupId, getOutputMarkupPlaceholderTag, getPage, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getResponse, getSession, getSizeInBytes, getStatelessHint, getString, getString, getString, getStyle, getVariation, hasBeenRendered, hasErrorMessage, hasFeedbackMessage, info, initModel, internalAttach, internalDetach, internalOnAttach, internalOnDetach, internalOnModelChanged, isActionAuthorized, isAncestorOf, isAttached, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isRenderAllowed, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, locateMarkupStream, markAttached, markRendering, modelChanged, modelChanging, onAfterRender, onAttach, onBeforeRender, onBeginRequest, onConfigure, onDetach, onEndRequest, onModelChanged, onModelChanging, onRemove, prepareForRender, prepareForRender, redirectToInterceptPage, remove, remove, render, render, renderComponent, renderComponent, renderComponentTag, rendered, renderPlaceholderTag, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, setAuto, setComponentBorder, setDefaultModelObject, setEnabled, setEscapeModelStrings, setFlag, setFlag, setIgnoreAttributeModifier, setMarkupId, setMarkupIdImpl, setMetaData, setOutputMarkupId, setOutputMarkupPlaceholderTag, setRedirect, setRenderBodyOnly, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisibilityAllowed, setVisible, urlFor, urlFor, urlFor, urlFor, urlFor, urlFor, visitParents, warn, wrap
public ProgressBar(String id, ProgressionModel model)
public void renderHead(org.apache.wicket.markup.html.IHeaderResponse response)
renderHead
in interface org.apache.wicket.markup.html.IHeaderContributor
protected void onInitialize()
onInitialize
in class org.apache.wicket.Component
public void reset()
protected org.apache.wicket.model.AbstractReadOnlyModel<String> getLabelModel(ProgressionModel model)
model
- the ProgressionModelprotected org.apache.wicket.model.IModel<String> getMessageModel(ProgressionModel model)
model
- the ProgressionModelpublic void start(org.apache.wicket.ajax.AjaxRequestTarget target)
target
- protected void update(Progression progression, org.apache.wicket.ajax.AjaxRequestTarget target)
Progression.isDone()
is true, even if main thread that calls the class terminates
the ajax thread will keep polling this (via DynamicAjaxSelfUpdatingTimerBehavior
.onPostProcessTarget()progression
- as Progressionprotected void onFinished(org.apache.wicket.ajax.AjaxRequestTarget target)
target
- public org.apache.wicket.util.time.Duration getRefreshDuration()
public void setRefreshDuration(org.apache.wicket.util.time.Duration refreshDuration)
Copyright © 2018. All rights reserved.