net.sf.tacos.demo.pages.ajax
Class ProgressBarExample

java.lang.Object
  extended by org.apache.hivemind.impl.BaseLocatable
      extended by org.apache.tapestry.AbstractComponent
          extended by org.apache.tapestry.BaseComponent
              extended by org.apache.tapestry.AbstractPage
                  extended by org.apache.tapestry.html.BasePage
                      extended by net.sf.tacos.demo.pages.ajax.ProgressBarExample
All Implemented Interfaces:
EventListener, Locatable, LocationHolder, org.apache.tapestry.event.PageBeginRenderListener, org.apache.tapestry.IComponent, org.apache.tapestry.IDirect, org.apache.tapestry.IPage, org.apache.tapestry.IRender, org.apache.tapestry.ITemplateComponent

public abstract class ProgressBarExample
extends org.apache.tapestry.html.BasePage
implements org.apache.tapestry.IDirect, org.apache.tapestry.event.PageBeginRenderListener

Demonstrates use of ProgressBar component to render progress of threaded work.

Author:
Jesse Kuhnert

Constructor Summary
ProgressBarExample()
           
 
Method Summary
 String getEstimatedTimeLeft()
          Calculates amount of time left, in minutes, for task.
abstract  ProgressWorkThread getProgressWorker()
          Worker doing import
abstract  long getStartTime()
          Gets start time
 boolean isImporting()
           
 void pageBeginRender(org.apache.tapestry.event.PageEvent evt)
          We are using a progress bar that does not hide itself when its worker completes (so that we can then apply effects, e.g.
abstract  void setProgressWorker(ProgressWorkThread worker)
          sets worker doing import
abstract  void setStartTime(long time)
          Set time - in milliseconds - that worker started
 boolean shouldStartRefreshes()
          This controls if we should start client side refreshes of the progress bar.
 void startTask(org.apache.tapestry.IRequestCycle cycle)
          Starts the progress task.
 void trigger(org.apache.tapestry.IRequestCycle cycle)
          
 
Methods inherited from class org.apache.tapestry.html.BasePage
getResponseContentType
 
Methods inherited from class org.apache.tapestry.AbstractPage
addPageAttachListener, addPageBeginRenderListener, addPageDetachListener, addPageEndRenderListener, addPageRenderListener, addPageValidateListener, attach, beginPageRender, beginResponse, detach, endPageRender, firePageAttached, firePageBeginRender, firePageDetached, firePageEndRender, firePageValidate, getChangeObserver, getEngine, getExtendedId, getGlobal, getIdPath, getLocale, getNestedComponent, getOutputEncoding, getPageName, getRequestCycle, getVisit, initialize, removePageAttachListener, removePageBeginRenderListener, removePageDetachListener, removePageEndRenderListener, removePageRenderListener, removePageValidateListener, renderPage, setChangeObserver, setLocale, setPageName, validate
 
Methods inherited from class org.apache.tapestry.BaseComponent
addOuter, finishLoad, renderComponent
 
Methods inherited from class org.apache.tapestry.AbstractComponent
addAsset, addBody, addComponent, checkActiveLock, cleanupAfterRender, enterActiveState, finishLoad, format, format, format, format, getAsset, getAssets, getBeans, getBinding, getBindingNames, getBindings, getBody, getBodyCount, getComponent, getComponents, getContainedComponent, getContainer, getId, getListeners, getMessage, getMessages, getNamespace, getPage, getProperty, getSpecification, isInActiveState, isParameterBound, isRendering, pageEndRender, prepareForRender, render, renderBody, renderInformalParameters, setBinding, setContainedComponent, setContainer, setId, setNamespace, setPage, setProperty, toString
 
Methods inherited from class org.apache.hivemind.impl.BaseLocatable
getLocation, setLocation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.tapestry.IDirect
isStateful
 
Methods inherited from interface org.apache.tapestry.IComponent
addAsset, addBody, addComponent, enterActiveState, finishLoad, getAsset, getAssets, getBeans, getBinding, getBindingNames, getBindings, getComponent, getComponents, getContainedComponent, getContainer, getExtendedId, getId, getIdPath, getListeners, getMessage, getMessages, getNamespace, getPage, getProperty, getSpecification, isRendering, renderBody, setBinding, setContainedComponent, setContainer, setId, setNamespace, setPage, setProperty
 
Methods inherited from interface org.apache.tapestry.IRender
render
 
Methods inherited from interface org.apache.hivemind.LocationHolder
setLocation
 
Methods inherited from interface org.apache.hivemind.Locatable
getLocation
 

Constructor Detail

ProgressBarExample

public ProgressBarExample()
Method Detail

getProgressWorker

public abstract ProgressWorkThread getProgressWorker()
Worker doing import


setProgressWorker

public abstract void setProgressWorker(ProgressWorkThread worker)
sets worker doing import


setStartTime

public abstract void setStartTime(long time)
Set time - in milliseconds - that worker started


getStartTime

public abstract long getStartTime()
Gets start time


pageBeginRender

public void pageBeginRender(org.apache.tapestry.event.PageEvent evt)
We are using a progress bar that does not hide itself when its worker completes (so that we can then apply effects, e.g. fade it out). So, if this is NOT triggered by the ajaxdirect service, check if the worker has finished and make it null. This prevents the progress bar from showing up when the browser is refreshed, or the page revisited.

Specified by:
pageBeginRender in interface org.apache.tapestry.event.PageBeginRenderListener

isImporting

public boolean isImporting()
Returns:
True if currently importing a casebase file.

shouldStartRefreshes

public boolean shouldStartRefreshes()
This controls if we should start client side refreshes of the progress bar. It is needed when we load this page and a worker is already running.

Returns:

getEstimatedTimeLeft

public String getEstimatedTimeLeft()
Calculates amount of time left, in minutes, for task.

Returns:

trigger

public void trigger(org.apache.tapestry.IRequestCycle cycle)

Specified by:
trigger in interface org.apache.tapestry.IDirect

startTask

public void startTask(org.apache.tapestry.IRequestCycle cycle)
               throws Exception
Starts the progress task.

Parameters:
cycle -
Throws:
Exception - on error