Hi,

On Mon, May 5, 2014 at 7:18 PM, Richard W. Adams <rwada...@up.com> wrote:

> We have a requirement to implement a progress bar for long-running server
> operations. We can't use the code at
> https://github.com/wicketstuff/core/wiki/Progressbar, because it doesn't
> meet our corporate user interface look-and-feel standards.
>

Have you considered providing your own .css ?
https://github.com/wicketstuff/core/blob/wicket-6.x/jdk-1.6-parent/progressbar-parent/progressbar/src/main/java/org/wicketstuff/progressbar/ProgressBar.java#L109


>
> So, we started our own implementation. Our test page contains these
> methods below (the TestExecutor below class implements
> Callable<ExecutorResult>).
>
>
> //----------------------------------------------------------------------------------------------
> private Component createButton() {
>         return new AjaxButton("start-button") {
>                 private static final long serialVersionUID = -1;
>
>                 @Override protected void onSubmit(final AjaxRequestTarget
> ajax, final Form<?> form) {
>
>                         final ExecutorService service = Executors.
> newSingleThreadExecutor();
>                         try {
>                                 final ProgressBarTestPage page =
> ProgressBarTestPage.this;
>                                 final TransactionData data = new
> TransactionData (page.getId(), false);
>                                 final TestExecutor executor = new
> TestExecutor(data, getPermissions());
>
>                                 executor.addListener(page);     // Request
> notification when done
>                                 future = service.submit(executor); //
> Begin execution
>                                 progressBarUpdater.start(ajax, executor);
> // Start polling for progress
>
>                         } catch (final Exception ex) {
>                                 throw new RuntimeException(ex);
>                         }
>                         service.shutdown();     // Terminate gracefully
> (VM probably
>                 }               //      won't exit if we fail to do this)
>         };
> }
>
> //----------------------------------------------------------------------------------------------
> /**
>    Observer Pattern method to let us know when the task is done so we can
> check how things went.
> */
> @Override public void executionComplete(final EnmCallableExecutor
> executor) {
>
>         try {
>                 if (!future.isCancelled()) {                            //
> Unless execution was canceled
>                         final ExecutorResult result = future.get();     //
> Get the outcome
>                         System.out.println(result);
>                         /*
>                          * TODO: Show success or error message
>                          */
>                 }
>         } catch (final Exception ex) {
>                 ex.printStackTrace();
>         }
> }
>
> The ProgessBarUpdater class has this method:
>
>
> //----------------------------------------------------------------------------------------------
> /**
>  * Displays the progress bar &amp; begins the polling. We don't start the
> polling until
>  * explicitly told to do, for efficiency purposes.
>  * @param ajax The Ajax request wrapper.
>  * @param reporter The object to query for progress data.
>  */
> public void start(final AjaxRequestTarget ajax, final ProgressReporter
> reporter) {
>
>         add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(2)) {
>                 private static final long serialVersionUID = 1L;
>
>                 @Override protected void onPostProcessTarget(final
> AjaxRequestTarget ajax) {
>
>                         final Progress progress = reporter.getProgress();
>                         final String script =                   // Build
> script to update
>                                 ProgressScript.build(progress);  //
> progress bar
>                         ajax.appendJavascript(script);
>                         if (progress == null) {                 // If
> operation is finished
>                                 final ProgressBarUpdater updater =
>                                         ProgressBarUpdater.this;
>                                 updater.remove(this);                   //
> Stop timer to prevent
>                                 ajax.addComponent(updater);  // pointless
> polling
>                         }
>                 }
>         });
>         ajax.addComponent(this);
> }
>
> The page also contains a Future object so we can check the result after
> the thread finishes:
>
>         private Future<ExecutorResult> future;
>
> __________________________________________
>
> Having said all that, here's the problem: When I click the page's button,
> Wicket throws this error:
>
>         Unable to serialize class: java.util.concurrent.FutureTask
>
> The FutureTask object, I believe, is coming from the service.submit call
> whose return value we store in our Future variable.
>
> Does anyone know how to get around this roadblock?
>
>
>
> **
>
> This email and any attachments may contain information that is
> confidential and/or privileged for the sole use of the intended recipient.
>  Any use, review, disclosure, copying, distribution or reliance by others,
> and any forwarding of this email or its contents, without the express
> permission of the sender is strictly prohibited by law.  If you are not the
> intended recipient, please contact the sender immediately, delete the
> e-mail and destroy all copies.
> **
>

Reply via email to