public class CountingUpThenAutoRefreshingLabel
extends org.apache.wicket.markup.html.panel.Panel
Usage:
<!-- In HTML file -->
<span wicket:id="numberOfUsers"></span>
// In Java file
CountingUpThenAutoRefreshingLabel label = new CountingUpThenAutoRefreshingLabel("numberOfUsers");
label.setDefaultModel(new PropertyModel(dataSource, "userCount")); // model returns Integer
add(label);
The first phase of the component lasts two minutes, and the value counts up from zero to the target value. It "tends" towards the target value, i.e. moves fast at the beginning, then slows down as it approaches its target value.
The second phase, triggered after the first two minutes, simply refreshes the value periodically from the server. Initially this is refreshed every two seconds, but this refresh interval is gradually slowed down, so that if N users leave their browsers open for a long time, we will not get N requests every two seconds forever.
Various numerical values above may be altered with:
label.setCountingUpDurationSeconds(120);
label.setCountingUpRefreshIntervalSeconds(0.1);
label.setTendencyThreshold(0.001);
label.setAutoRefreshingInitialIntervalSeconds(2.0);
label.setAutoRefreshingIntervalMultiplier(1.2); | Modifier and Type | Field and Description |
|---|---|
protected double |
autoRefreshingIntervalMultiplier |
protected double |
autoRefreshIntervalSeconds |
protected double |
countingUpDurationSeconds |
protected double |
countingUpRefreshIntervalSeconds |
protected org.apache.wicket.ajax.AbstractAjaxTimerBehavior |
currentSelfUpdatingBehavior |
protected org.apache.wicket.markup.html.basic.Label |
js |
protected org.apache.wicket.markup.html.basic.Label |
label |
protected double |
tendencyThreshold |
| Constructor and Description |
|---|
CountingUpThenAutoRefreshingLabel(String wicketId) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
autoRefreshCallback(org.apache.wicket.ajax.AjaxRequestTarget target) |
String |
getJs()
INTERNAL METHOD -- DO NOT USE
|
String |
getLabelValue()
INTERNAL METHOD -- DO NOT USE
|
protected String |
getThousandSeparator() |
void |
setAutoRefreshingInitialIntervalSeconds(double x)
During the auto-refresh phase, what should the duration be between server-refreshes, initially?
|
void |
setAutoRefreshingIntervalMultiplier(double x)
During the auto-refresh phase, by what multiplier should the auto-refresh interval durations increase? For example 2.0
means they double; so for example the first duration might be 10s, the next 20s, the next 40s, etc.
|
void |
setCountingUpDurationSeconds(double x)
How long should the initial phase of counting up be? Measured in seconds
|
void |
setCountingUpRefreshIntervalSeconds(double x)
What should the duration between the updates during the counting up phase be? Measured in seconds.
|
void |
setTendencyThreshold(double x)
How close should the counting up phase get to the target value? A value of 0.01 means it gets within 1% of the target value
before switching to the second auto-refresh phase.
|
getRegionMarkup, newMarkupSourcingStrategygetWebApplication, getWebPage, getWebRequest, getWebResponse, getWebSessionadd, addDequeuedComponent, addOrReplace, autoAdd, canDequeueTag, contains, dequeue, dequeue, dequeuePreamble, findChildComponent, findComponentToDequeue, get, getAssociatedMarkup, getAssociatedMarkupStream, getMarkup, getMarkupType, internalAdd, internalInitialize, iterator, iterator, newDequeueContext, onComponentTagBody, onDetach, onInitialize, onRender, queue, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderNext, replace, setDefaultModel, size, stream, streamChildren, toString, toString, visitChildren, visitChildrenadd, addStateChange, beforeRender, canCallListener, canCallListenerAfterExpiry, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, clearOriginalDestination, configure, continueToOriginalDestination, createConverter, debug, detach, detachModel, detachModels, determineVisibility, error, exceptionMessage, fatal, findMarkupStream, findPage, findParent, findParentWithAssociatedMarkup, getAjaxRegionMarkupId, getApplication, getBehaviorById, getBehaviorId, getBehaviors, getBehaviors, getClassRelativePath, getConverter, getDefaultModel, getDefaultModelObject, getDefaultModelObjectAsString, getDefaultModelObjectAsString, getEscapeModelStrings, getFeedbackMessages, getFlag, getId, getInnermostModel, getInnermostModel, getLocale, getLocalizer, getMarkup, getMarkupAttributes, getMarkupId, getMarkupId, getMarkupIdFromMarkup, getMarkupIdImpl, getMarkupSourcingStrategy, getMetaData, getModelComparator, getOutputMarkupId, getOutputMarkupPlaceholderTag, getPage, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getRequestFlag, getResponse, getSession, getSizeInBytes, getStatelessHint, getString, getString, getString, getStyle, getVariation, hasBeenRendered, hasErrorMessage, hasFeedbackMessage, info, initModel, internalOnModelChanged, internalRenderComponent, internalRenderHead, isActionAuthorized, isAuto, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isInitialized, isRenderAllowed, isRendering, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, markRendering, modelChanged, modelChanging, onAfterRender, onBeforeRender, onComponentTag, onConfigure, onEvent, onModelChanged, onModelChanging, onReAdd, onRemove, redirectToInterceptPage, remove, remove, render, renderComponentTag, rendered, renderHead, renderPart, renderPlaceholderTag, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, send, setAuto, setDefaultModelObject, setEnabled, setEscapeModelStrings, setFlag, setIgnoreAttributeModifier, setMarkup, setMarkupId, setMarkupIdImpl, setMetaData, setOutputMarkupId, setOutputMarkupPlaceholderTag, setParent, setRenderBodyOnly, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisibilityAllowed, setVisible, success, urlFor, urlFor, urlFor, urlForListener, urlForListener, visitParents, visitParents, warn, wrapclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitforEach, spliteratorprotected double countingUpDurationSeconds
protected double countingUpRefreshIntervalSeconds
protected double tendencyThreshold
protected double autoRefreshingIntervalMultiplier
protected org.apache.wicket.markup.html.basic.Label label
protected org.apache.wicket.markup.html.basic.Label js
protected org.apache.wicket.ajax.AbstractAjaxTimerBehavior currentSelfUpdatingBehavior
protected double autoRefreshIntervalSeconds
public CountingUpThenAutoRefreshingLabel(String wicketId)
public void setCountingUpDurationSeconds(double x)
public void setCountingUpRefreshIntervalSeconds(double x)
public void setTendencyThreshold(double x)
public void setAutoRefreshingInitialIntervalSeconds(double x)
public void setAutoRefreshingIntervalMultiplier(double x)
public String getLabelValue()
protected String getThousandSeparator()
public String getJs()
protected void autoRefreshCallback(org.apache.wicket.ajax.AjaxRequestTarget target)
Copyright © 2003–2018. All rights reserved.