Hi. I have looked at removing the timer from a component when a condition is not true, but according to the forums this is not possible.
Recommended is the use of isEnabled. I have the following code, but isEnabled doesn't appear to be working. I'm after a way of allowing a user to start a process by pressing a link, then as the process continues over several minutes the WebMarkupContainer is updated (every 5 seconds using an AjaxSelfUpdatingTimerBehavior) and when the process finishes, stopping the timerbahavior until the link is next pressed. I think this must be a common thing to do so any information would be most welcome. My refresh link that the user presses to render an indicator and a percentage based on the fact a refresh is occuring: public final class RefreshLink extends AbstractAjaxFallbackButtonLink { private static final long serialVersionUID = 1825145981122180572L; @Override public void onClick( AjaxRequestTarget target ) { // create the refresh process worker RefreshWorker refreshWorker = new RefreshWorker(); // execute the refresh thread refreshWorker.refresh( Visit.get() ); // get the page AccountViewPage page = AccountViewPage.class.cast( getPage() ); // get a reference to the markup container component containing a refresh indicator and percentage complete Component container = page.get( RefreshPanel.CONTAINER_ID_PATH ); target.addComponent( container ); } } In the panel containing the indicator (shown as the process continues along with a percentage complete): : WebMarkupContainer container = new WebMarkupContainer( CONTAINER ); Image refreshIndicator = new Image( REFRESH_INDICATOR, IconFactory.getSmallGIF( REFRESH_INDICATOR ) ); AttributeModifier attributeModifier = new RefreshImageAttributeModifier(); Label percentageCompleteLabel = new Label( PERCENTAGE_COMPLETE_LABEL, new RefreshLabelReadOnlyModel() ); container.add( percentageLabel ); container.add( refreshIndicator ); container.add( attributeModifier ); container.setOutputMarkupId( true ); container.add( new RefreshTimerBehavior() ); add( refreshButton ); add( container ); : And the refresh timer: public final class RefreshTimerBehavior extends AjaxSelfUpdatingTimerBehavior { private static final long serialVersionUID = -6061033495202259806L; private static final int FIVE_SECONDS = 5; /** * @param updateInterval */ public RefreshTimerBehavior() { super( Duration.seconds( FIVE_SECONDS ) ); } /* * (non-Javadoc) * * @see org.apache.wicket.behavior.AbstractBehavior#isEnabled(org.apache.wicket.Component) */ @Override public boolean isEnabled( Component component ) { boolean isEnabled = false; if( Visit.get().isRefreshing() ) { isEnabled = true; } return isEnabled; } } Now, isEnabled is getting called, but the base class method onTimer is also getting called - indicating to me that the value of isEnabled is being ignored - I was hoping that a return value of false would tell the timer to stop, but it keeps ticking away every five seconds. I obviously can't remove the timer behavior but I would like to disable and enable it in the following conditions: 1) Enable: The timer gets enabled (i.e. isEnabled is true?) on Visit.get().isRefreshing() equal to 'true'. 2) Disable: The timer gets disabled (i.e. isEnabled is false?) on Visit.get().isRefreshing() equal to 'false'. I simply only want the timer to tick when the refreshing process via the worker is occuring and not otherwise. I hope this is clear... Any thoughts? This is with 1.3.5 Wicket. Many thanks for your time, Graeme. -- View this message in context: http://www.nabble.com/isEnabled-on-AjaxSelfUpdatingTimerBehavior.-tp20532502p20532502.html Sent from the Wicket - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]