@Override
 protected void onComponentTag(ComponentTag tag) {
   checkComponentTag(tag, "progress");
   super.onComponentTag(tag);
   tag.put("value", value.get());
   tag.put("max", max.get());
 }
  @Override
  protected void onInitialize() {
    super.onInitialize();
    final AjaxSelfUpdatingTimerBehavior ajaxSelfUpdatingTimerBehavior =
        new AjaxSelfUpdatingTimerBehavior(duration) {
          private static final long serialVersionUID = 1L;

          @Override
          protected void onPostProcessTarget(AjaxRequestTarget target) {
            target.add(Progress.this);
            // Check if the process started
            if (process.get()) {
              // If the task has been finished and the value exceeds the
              // max value stop the self updating timer behavior and call
              // done so that the user is able to refresh its components
              if (value.get() >= max.get()) {
                stop(target);
                done(target);
              }
            }
          }
        };
    add(ajaxSelfUpdatingTimerBehavior);
    Thread refreshingThread =
        new Thread() {
          @Override
          public void run() {
            // Run the init process method in a separate thread so that
            // the actual thread is moved on and update process value is triggert
            // to check the state
            Thread processThread =
                new Thread() {
                  @Override
                  public void run() {
                    initProcess();
                  };
                };
            processThread.start();

            // The user override the method updateProcessValue and each time an increased
            // number is going to be returned
            while (value.get() <= max.get()) {
              try {
                Thread.sleep(duration.getMilliseconds());
              } catch (InterruptedException e) {
                // OUCHY!!
              }
              value.set(updateProcessValue());
              process.set(true);
            }
          }
        };
    refreshingThread.start();
  }
Example #3
0
  /** @see org.apache.wicket.Component#onComponentTag(ComponentTag) */
  @Override
  protected void onComponentTag(final ComponentTag tag) {
    checkComponentTag(tag, "img");
    super.onComponentTag(tag);
    final IResource resource = getImageResource();
    if (resource != null) {
      localizedImageResource.setResource(resource);
    }
    final ResourceReference resourceReference = getImageResourceReference();
    if (resourceReference != null) {
      localizedImageResource.setResourceReference(resourceReference);
    }
    localizedImageResource.setSrcAttribute(tag);

    if (shouldAddAntiCacheParameter()) {
      addAntiCacheParameter(tag);
    }
  }
 /*
  * (non-Javadoc)
  * @see org.apache.wicket.Component#onComponentTag(org.apache.wicket.markup.ComponentTag)
  */
 @Override
 protected void onComponentTag(ComponentTag tag) {
   super.onComponentTag(tag);
   // make sure that our JS button will render in the container of right tag
   tag.setName("div");
 }