You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "Richard W. Adams" <RW...@UP.COM> on 2014/05/05 19:18:41 UTC
Progress Bar
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.
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 & 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.
**
Re: AjaxSelfUpdatingTimerBehavior.onPostProcessTarget() Never Called
Posted by "Richard W. Adams" <RW...@UP.COM>.
I finally got the onTimer() to execute. Had to change my button onclick()
code to this:
add(new ProgressUpdateBehavior(executor));
ajax.addComponent(this);
It began working when I added the second line above. Without that, the
client didn't receive the updated
component with the new timer script.
**
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.
**
Re: AjaxSelfUpdatingTimerBehavior.onPostProcessTarget() Never Called
Posted by "Richard W. Adams" <RW...@UP.COM>.
Some further info: I changed my class to extend Label instead of Component
, and removed the onRender() override. But onPostProcessTarget() is still
not called. Any suggestions would be greatly appreciated!
From: Sven Meier <sv...@meiers.net>
To: users@wicket.apache.org
Date: 05/06/2014 04:37 PM
Subject: Re: AjaxSelfUpdatingTimerBehavior.onPostProcessTarget()
Never Called
By overriding #onRender() you're preventing the component tag to be
written into the response.
Since wicket-ajax cannot find the markuo id in the DOM, it will not
perform the Ajax request.
Sven
On 05/06/2014 08:28 PM, Richard W. Adams wrote:
> The onPostProcessTarget() method of my AjaxSelfUpdatingTimerBehavior is
> not being called for some reason. Here's the code. I can see the start()
> method being called (when the user clicks my "Start" button), but
> onPostProcessTarget() is never invoked. What am I doing wrong? Do I need
> to use some different sort of timer?
>
>
//----------------------------------------------------------------------------------------------
> @Override protected void onRender(final MarkupStream stream) {
> /*
> * Does nothing. This component has no markup of its own.
> * It exists only to update the progress bar.
> */
> System.out.println("In ProgressBarUpdater.onRender()");
> stream.next(); // Keep Wicket from complaining about not
> advancing the markup stream
> }
>
//----------------------------------------------------------------------------------------------
> /**
> * Opens the Ricola progress bar & begins the polling. We don't
start
> the polling until
> * explicitly told to so 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) {
>
> final AjaxSelfUpdatingTimerBehavior behavior = new
> AjaxSelfUpdatingTimerBehavior(Duration.seconds(2)) {
> private static final long serialVersionUID = 1L;
>
> @Override protected void onPostProcessTarget(final
> AjaxRequestTarget ajax) {
>
> System.out.printf("In onPostProcessTarget()");
> super.onPostProcessTarget(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
> }
> }
> };
> add(behavior);
> ajax.addComponent(this);
> }
>
//----------------------------------------------------------------------------------------------
>
> Here's the markup for the ProgressBarUpdater, the component to which
these
> methods belong:
>
> <span wicket:id="progress-updater"></span>
>
>
>
> From: Martin Grigorov <mg...@apache.org>
> To: "users@wicket.apache.org" <us...@wicket.apache.org>
> Date: 05/05/2014 03:32 PM
> Subject: Re: Progress Bar
>
>
>
> Hi,
>
>
> On Mon, May 5, 2014 at 7:18 PM, Richard W. Adams <RW...@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 & 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.
>> **
>>
>
>
> **
>
> 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.
> **
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
**
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.
**
Re: AjaxSelfUpdatingTimerBehavior.onPostProcessTarget() Never Called
Posted by "Richard W. Adams" <RW...@UP.COM>.
I tried simplifying the design by extending AbstractAjaxTimerBehavior
instead, but still can't get it to do anything. In the following class,
the onTimer() method is never called:
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AbstractAjaxTimerBehavior;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.util.time.Duration;
import com.uprr.eni.commons.util.progress.Progress;
import com.uprr.eni.commons.util.progress.ProgressReporter;
import com.uprr.eni.commons.util.progress.ProgressScript;
//----------------------------------------------------------------------------------------------
/**
* Periodically sends JavaScript to the client to update the progress bar.
*/
public class ProgressUpdateBehavior extends AbstractAjaxTimerBehavior {
private static final long serialVersionUID = 6685938921228093681L;
private final ProgressReporter reporter;
private final Component parent;
//----------------------------------------------------------------------------------------------
/**
* Constructor.
* @param reporter The object we will query for progress.
* @param parent The component to which this behavior is attached. The
behavior will remove
* itself from the parent when {@code reporter.getProgress()} returns
{@code null}.
*/
public ProgressUpdateBehavior(final ProgressReporter reporter, final
Component parent) {
super(Duration.seconds(2));
this.reporter = reporter;
this.parent = parent;
}
//----------------------------------------------------------------------------------------------
@Override protected void onTimer(final AjaxRequestTarget ajax) {
final Progress progress = reporter.getProgress();
final String script = ProgressScript.build(progress);
ajax.appendJavascript(script);
if (progress == null) {
parent.remove(this);
}
}
//----------------------------------------------------------------------------------------------
}
I add the above behavior to the page when the user clicks a button to
begin a long running task. I can see the background thread executing as
expected, but the timer behavior's onTimer() is never executed.
//----------------------------------------------------------------------------------------------
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
final Future<?> future = //
When/if task completes
service.submit(executor); //
Begin background thread
BACKGROUND_TASKS.put(currentUserName,
future); // Record what we're doing
add(new ProgressUpdateBehavior(executor,
this));// Start polling for progress
} catch (final Exception ex) {
throw new RuntimeException(ex);
}
service.shutdown();
}
};
}
From: Sven Meier <sv...@meiers.net>
To: users@wicket.apache.org
Date: 05/06/2014 04:37 PM
Subject: Re: AjaxSelfUpdatingTimerBehavior.onPostProcessTarget()
Never Called
By overriding #onRender() you're preventing the component tag to be
written into the response.
Since wicket-ajax cannot find the markuo id in the DOM, it will not
perform the Ajax request.
Sven
On 05/06/2014 08:28 PM, Richard W. Adams wrote:
> The onPostProcessTarget() method of my AjaxSelfUpdatingTimerBehavior is
> not being called for some reason. Here's the code. I can see the start()
> method being called (when the user clicks my "Start" button), but
> onPostProcessTarget() is never invoked. What am I doing wrong? Do I need
> to use some different sort of timer?
>
>
//----------------------------------------------------------------------------------------------
> @Override protected void onRender(final MarkupStream stream) {
> /*
> * Does nothing. This component has no markup of its own.
> * It exists only to update the progress bar.
> */
> System.out.println("In ProgressBarUpdater.onRender()");
> stream.next(); // Keep Wicket from complaining about not
> advancing the markup stream
> }
>
//----------------------------------------------------------------------------------------------
> /**
> * Opens the Ricola progress bar & begins the polling. We don't
start
> the polling until
> * explicitly told to so 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) {
>
> final AjaxSelfUpdatingTimerBehavior behavior = new
> AjaxSelfUpdatingTimerBehavior(Duration.seconds(2)) {
> private static final long serialVersionUID = 1L;
>
> @Override protected void onPostProcessTarget(final
> AjaxRequestTarget ajax) {
>
> System.out.printf("In onPostProcessTarget()");
> super.onPostProcessTarget(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
> }
> }
> };
> add(behavior);
> ajax.addComponent(this);
> }
>
//----------------------------------------------------------------------------------------------
>
> Here's the markup for the ProgressBarUpdater, the component to which
these
> methods belong:
>
> <span wicket:id="progress-updater"></span>
>
>
>
> From: Martin Grigorov <mg...@apache.org>
> To: "users@wicket.apache.org" <us...@wicket.apache.org>
> Date: 05/05/2014 03:32 PM
> Subject: Re: Progress Bar
>
>
>
> Hi,
>
>
> On Mon, May 5, 2014 at 7:18 PM, Richard W. Adams <RW...@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 & 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.
>> **
>>
>
>
> **
>
> 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.
> **
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
**
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.
**
Re: AjaxSelfUpdatingTimerBehavior.onPostProcessTarget() Never Called
Posted by "Richard W. Adams" <RW...@UP.COM>.
Fair enough. But I have use a Component, since
AjaxSelfUpdatingTimerBehavioronly works on a component. Which means I have
to implement the abstract onRender() method. What's the minimum action my
onRender() needs to do, considering I just want an invisible component?
Or is there some other way to accomplish this automatic push of JavaScript
without re-rendering the entire page on every update?
From: Sven Meier <sv...@meiers.net>
To: users@wicket.apache.org
Date: 05/06/2014 04:37 PM
Subject: Re: AjaxSelfUpdatingTimerBehavior.onPostProcessTarget()
Never Called
By overriding #onRender() you're preventing the component tag to be
written into the response.
Since wicket-ajax cannot find the markuo id in the DOM, it will not
perform the Ajax request.
Sven
On 05/06/2014 08:28 PM, Richard W. Adams wrote:
> The onPostProcessTarget() method of my AjaxSelfUpdatingTimerBehavior is
> not being called for some reason. Here's the code. I can see the start()
> method being called (when the user clicks my "Start" button), but
> onPostProcessTarget() is never invoked. What am I doing wrong? Do I need
> to use some different sort of timer?
>
>
//----------------------------------------------------------------------------------------------
> @Override protected void onRender(final MarkupStream stream) {
> /*
> * Does nothing. This component has no markup of its own.
> * It exists only to update the progress bar.
> */
> System.out.println("In ProgressBarUpdater.onRender()");
> stream.next(); // Keep Wicket from complaining about not
> advancing the markup stream
> }
>
//----------------------------------------------------------------------------------------------
> /**
> * Opens the Ricola progress bar & begins the polling. We don't
start
> the polling until
> * explicitly told to so 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) {
>
> final AjaxSelfUpdatingTimerBehavior behavior = new
> AjaxSelfUpdatingTimerBehavior(Duration.seconds(2)) {
> private static final long serialVersionUID = 1L;
>
> @Override protected void onPostProcessTarget(final
> AjaxRequestTarget ajax) {
>
> System.out.printf("In onPostProcessTarget()");
> super.onPostProcessTarget(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
> }
> }
> };
> add(behavior);
> ajax.addComponent(this);
> }
>
//----------------------------------------------------------------------------------------------
>
> Here's the markup for the ProgressBarUpdater, the component to which
these
> methods belong:
>
> <span wicket:id="progress-updater"></span>
>
>
>
> From: Martin Grigorov <mg...@apache.org>
> To: "users@wicket.apache.org" <us...@wicket.apache.org>
> Date: 05/05/2014 03:32 PM
> Subject: Re: Progress Bar
>
>
>
> Hi,
>
>
> On Mon, May 5, 2014 at 7:18 PM, Richard W. Adams <RW...@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 & 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.
>> **
>>
>
>
> **
>
> 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.
> **
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
**
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.
**
Re: AjaxSelfUpdatingTimerBehavior.onPostProcessTarget() Never Called
Posted by Sven Meier <sv...@meiers.net>.
By overriding #onRender() you're preventing the component tag to be
written into the response.
Since wicket-ajax cannot find the markuo id in the DOM, it will not
perform the Ajax request.
Sven
On 05/06/2014 08:28 PM, Richard W. Adams wrote:
> The onPostProcessTarget() method of my AjaxSelfUpdatingTimerBehavior is
> not being called for some reason. Here's the code. I can see the start()
> method being called (when the user clicks my "Start" button), but
> onPostProcessTarget() is never invoked. What am I doing wrong? Do I need
> to use some different sort of timer?
>
> //----------------------------------------------------------------------------------------------
> @Override protected void onRender(final MarkupStream stream) {
> /*
> * Does nothing. This component has no markup of its own.
> * It exists only to update the progress bar.
> */
> System.out.println("In ProgressBarUpdater.onRender()");
> stream.next(); // Keep Wicket from complaining about not
> advancing the markup stream
> }
> //----------------------------------------------------------------------------------------------
> /**
> * Opens the Ricola progress bar & begins the polling. We don't start
> the polling until
> * explicitly told to so 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) {
>
> final AjaxSelfUpdatingTimerBehavior behavior = new
> AjaxSelfUpdatingTimerBehavior(Duration.seconds(2)) {
> private static final long serialVersionUID = 1L;
>
> @Override protected void onPostProcessTarget(final
> AjaxRequestTarget ajax) {
>
> System.out.printf("In onPostProcessTarget()");
> super.onPostProcessTarget(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
> }
> }
> };
> add(behavior);
> ajax.addComponent(this);
> }
> //----------------------------------------------------------------------------------------------
>
> Here's the markup for the ProgressBarUpdater, the component to which these
> methods belong:
>
> <span wicket:id="progress-updater"></span>
>
>
>
> From: Martin Grigorov <mg...@apache.org>
> To: "users@wicket.apache.org" <us...@wicket.apache.org>
> Date: 05/05/2014 03:32 PM
> Subject: Re: Progress Bar
>
>
>
> Hi,
>
>
> On Mon, May 5, 2014 at 7:18 PM, Richard W. Adams <RW...@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 & 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.
>> **
>>
>
>
> **
>
> 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.
> **
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
AjaxSelfUpdatingTimerBehavior.onPostProcessTarget() Never Called
Posted by "Richard W. Adams" <RW...@UP.COM>.
The onPostProcessTarget() method of my AjaxSelfUpdatingTimerBehavior is
not being called for some reason. Here's the code. I can see the start()
method being called (when the user clicks my "Start" button), but
onPostProcessTarget() is never invoked. What am I doing wrong? Do I need
to use some different sort of timer?
//----------------------------------------------------------------------------------------------
@Override protected void onRender(final MarkupStream stream) {
/*
* Does nothing. This component has no markup of its own.
* It exists only to update the progress bar.
*/
System.out.println("In ProgressBarUpdater.onRender()");
stream.next(); // Keep Wicket from complaining about not
advancing the markup stream
}
//----------------------------------------------------------------------------------------------
/**
* Opens the Ricola progress bar & begins the polling. We don't start
the polling until
* explicitly told to so 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) {
final AjaxSelfUpdatingTimerBehavior behavior = new
AjaxSelfUpdatingTimerBehavior(Duration.seconds(2)) {
private static final long serialVersionUID = 1L;
@Override protected void onPostProcessTarget(final
AjaxRequestTarget ajax) {
System.out.printf("In onPostProcessTarget()");
super.onPostProcessTarget(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
}
}
};
add(behavior);
ajax.addComponent(this);
}
//----------------------------------------------------------------------------------------------
Here's the markup for the ProgressBarUpdater, the component to which these
methods belong:
<span wicket:id="progress-updater"></span>
From: Martin Grigorov <mg...@apache.org>
To: "users@wicket.apache.org" <us...@wicket.apache.org>
Date: 05/05/2014 03:32 PM
Subject: Re: Progress Bar
Hi,
On Mon, May 5, 2014 at 7:18 PM, Richard W. Adams <RW...@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 & 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.
> **
>
**
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.
**
Background Task in Separate Thread
Posted by "Richard W. Adams" <RW...@UP.COM>.
I was probably overly wordy & not very clear on the details of our
problem. The client side isn't the issue: We display the client progress
bar via JavaScript & it's been working fine for a number of years. Our
challenge is on the server side: Managing the background task in a
separate thread. We have three basic requirements for the background task.
It must:
1. Be cancellable.
2. Report its outcome (success/failure/warning).
3. Report incremental progress.
Graceful handling of the thread outcome is an unexpectedly a tough nut to
crack. The vast majority of examples we've seen use the Runnable interface
(which doesn't help us, as it can't be canceled or return a value), rather
than Callable interface (which meets our needs, but doesn't seem to play
well with Wicket, since java.util.concurrent.FutureTask isn't
Serializable).
From: Martin Grigorov <mg...@apache.org>
To: "users@wicket.apache.org" <us...@wicket.apache.org>
Date: 05/05/2014 03:32 PM
Subject: Re: Progress Bar
Hi,
On Mon, May 5, 2014 at 7:18 PM, Richard W. Adams <RW...@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 & 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.
> **
>
**
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.
**
Re: Progress Bar
Posted by Martin Grigorov <mg...@apache.org>.
Hi,
On Mon, May 5, 2014 at 7:18 PM, Richard W. Adams <RW...@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 & 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.
> **
>
Re: Application Scope
Posted by "Richard W. Adams" <RW...@UP.COM>.
To clarify: Are you saying that we should add our own setTask() &
getTask() methods to our application class? And then maintain a task map
as a member variable of our application class?
From: Martin Grigorov <mg...@apache.org>
To: "users@wicket.apache.org" <us...@wicket.apache.org>
Date: 05/06/2014 08:06 AM
Subject: Re: Application Scope
Please don't change the thread subject for all your answers. This confuses
the threading support in some mail clients.
I meant *My*Application, i.e. *Your*Application.
Add this method and map/associate all tasks that your run to some id/key.
Serialize the key and later get a reference to the FutureTask with
something like:
YourApp.get().getTasks().get(theKey).isDone()/.isCanceled()/...
Martin Grigorov
Wicket Training and Consulting
On Tue, May 6, 2014 at 2:50 PM, Richard W. Adams <RW...@up.com> wrote:
> Are you referring to org.apache.wicket.Application? I don't see a
> getTasksMap() method there. We use Wicket 1.4.17 & our company will not
> allow us to upgrade to newer versions). If getTasksMap() is unavailable
in
> 1.4.17, could Application.getSharedResources() be used in a similar way?
>
>
>
>
> From: Martin Grigorov <mg...@apache.org>
> To: "users@wicket.apache.org" <us...@wicket.apache.org>
> Date: 05/06/2014 07:26 AM
> Subject: Re: Background Threading
>
>
>
> Hi,
>
> You can put the tasks in an application scoped structure (e.g.
> MyApplication.get().getTasksMap()) and use a serializable key.
>
> Martin Grigorov
> Wicket Training and Consulting
>
>
> On Tue, May 6, 2014 at 2:11 PM, Richard W. Adams <RW...@up.com>
wrote:
>
> > Interesting approach. Our use case is more complex, as it runs a
> > background task in a separate thread. Our task has three basic
> > requirements. It must:
> >
> > 1. Be cancellable.
> >
> > 2. Report its outcome (success/failure/warning).
> >
> > 3. Report incremental progress.
> >
> > Our fundamental problem is not how to display the progress bar, it's
how
> > to determine the outcome of the background thread. That's an
> unexpectedly
> > a tough nut to crack. The vast majority of examples we've seen use the
> > Runnable interface (which doesn't help us, as it can't be canceled or
> > return a value), rather than Callable interface (which meets our
needs,
> > but doesn't seem to play well with Wicket)
> >
> >
> >
> >
> > From: Colin Rogers <Co...@objectconsulting.com.au>
> > To: "users@wicket.apache.org" <us...@wicket.apache.org>
> > Date: 05/05/2014 08:14 PM
> > Subject: RE: Progress Bar
> >
> >
> >
> > There is a pretty nifty, jquery based progress bar, in
wicket-jquery-ui
> > library...
> >
> >
>
http://www.7thweb.net/wicket-jquery-ui/progressbar/DefaultProgressBarPage
> >
> > Cheers,
> > Col.
> >
> > -----Original Message-----
> > From: Richard W. Adams [mailto:RWADAMS1@UP.COM]
> > Sent: Tuesday, 6 May 2014 3:19 AM
> > To: users@wicket.apache.org
> > Subject: Progress Bar
> >
> > 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.
> >
> > 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 & 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.
> > **
> > EMAIL DISCLAIMER This email message and its attachments are
confidential
> > and may also contain copyright or privileged material. If you are not
> the
> > intended recipient, you may not forward the email or disclose or use
the
> > information contained in it. If you have received this email message
in
> > error, please advise the sender immediately by replying to this email
> and
> > delete the message and any associated attachments. Any views,
opinions,
> > conclusions, advice or statements expressed in this email message are
> > those of the individual sender and should not be relied upon as the
> > considered view, opinion, conclusions, advice or statement of this
> company
> > except where the sender expressly, and with authority, states them to
be
> > the considered view, opinion, conclusions, advice or statement of this
> > company. Every care is taken but we recommend that you scan any
> > attachments for viruses.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
> >
> >
> > **
> >
> > 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.
> > **
> >
>
>
>
> **
>
> 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.
> **
>
**
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.
**
Re: Application Scope
Posted by Tom Götz <to...@decoded.de>.
You can’t, and it isn’t a deficiency, just think about e.g. session replication among multiple cluster nodes.
Cheers,
-Tom
On 06.05.2014, at 15:52, Richard W. Adams <RW...@UP.COM> wrote:
> I assume that means we can't store non-serializable objects in the
> session? This is sounding like a serious deficiency in Wicket's
> architecture...
>
>
>
>
> From: Francois Meillet <fr...@gmail.com>
> To: users@wicket.apache.org
> Date: 05/06/2014 08:48 AM
> Subject: Re: Application Scope
>
>
>
> sessions are serialised
>
> François Meillet
> Formation Wicket - Développement Wicket
>
>
>
>
>
> Le 6 mai 2014 à 15:28, Richard W. Adams <RW...@UP.COM> a écrit :
>
>> One more question: Since each task is associated with a single user,
> would
>> it make more sense to create a task map in Session scope? Or will Wicket
>
>> try to serialize a map we put into the session?
>>
>>
>>
>>
>> From: Martin Grigorov <mg...@apache.org>
>> To: "users@wicket.apache.org" <us...@wicket.apache.org>
>> Date: 05/06/2014 08:06 AM
>> Subject: Re: Application Scope
>>
>>
>>
>> Please don't change the thread subject for all your answers. This
> confuses
>> the threading support in some mail clients.
>>
>> I meant *My*Application, i.e. *Your*Application.
>> Add this method and map/associate all tasks that your run to some
> id/key.
>> Serialize the key and later get a reference to the FutureTask with
>> something like:
>> YourApp.get().getTasks().get(theKey).isDone()/.isCanceled()/...
>>
>> Martin Grigorov
>> Wicket Training and Consulting
>>
>>
>> On Tue, May 6, 2014 at 2:50 PM, Richard W. Adams <RW...@up.com>
> wrote:
>>
>>> Are you referring to org.apache.wicket.Application? I don't see a
>>> getTasksMap() method there. We use Wicket 1.4.17 & our company will
> not
>>> allow us to upgrade to newer versions). If getTasksMap() is unavailable
>
>> in
>>> 1.4.17, could Application.getSharedResources() be used in a similar
> way?
>>>
>>>
>>>
>>>
>>> From: Martin Grigorov <mg...@apache.org>
>>> To: "users@wicket.apache.org" <us...@wicket.apache.org>
>>> Date: 05/06/2014 07:26 AM
>>> Subject: Re: Background Threading
>>>
>>>
>>>
>>> Hi,
>>>
>>> You can put the tasks in an application scoped structure (e.g.
>>> MyApplication.get().getTasksMap()) and use a serializable key.
>>>
>>> Martin Grigorov
>>> Wicket Training and Consulting
>>>
>>>
>>> On Tue, May 6, 2014 at 2:11 PM, Richard W. Adams <RW...@up.com>
>> wrote:
>>>
>>>> Interesting approach. Our use case is more complex, as it runs a
>>>> background task in a separate thread. Our task has three basic
>>>> requirements. It must:
>>>>
>>>> 1. Be cancellable.
>>>>
>>>> 2. Report its outcome (success/failure/warning).
>>>>
>>>> 3. Report incremental progress.
>>>>
>>>> Our fundamental problem is not how to display the progress bar, it's
>> how
>>>> to determine the outcome of the background thread. That's an
>>> unexpectedly
>>>> a tough nut to crack. The vast majority of examples we've seen use the
>>>> Runnable interface (which doesn't help us, as it can't be canceled or
>>>> return a value), rather than Callable interface (which meets our
>> needs,
>>>> but doesn't seem to play well with Wicket)
>>>>
>>>>
>>>>
>>>>
>>>> From: Colin Rogers <Co...@objectconsulting.com.au>
>>>> To: "users@wicket.apache.org" <us...@wicket.apache.org>
>>>> Date: 05/05/2014 08:14 PM
>>>> Subject: RE: Progress Bar
>>>>
>>>>
>>>>
>>>> There is a pretty nifty, jquery based progress bar, in
>> wicket-jquery-ui
>>>> library...
>>>>
>>>>
>>>
>>
> http://www.7thweb.net/wicket-jquery-ui/progressbar/DefaultProgressBarPage
>>>>
>>>> Cheers,
>>>> Col.
>>>>
>>>> -----Original Message-----
>>>> From: Richard W. Adams [mailto:RWADAMS1@UP.COM]
>>>> Sent: Tuesday, 6 May 2014 3:19 AM
>>>> To: users@wicket.apache.org
>>>> Subject: Progress Bar
>>>>
>>>> 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.
>>>>
>>>> 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 & 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.
>>>> **
>>>> EMAIL DISCLAIMER This email message and its attachments are
>> confidential
>>>> and may also contain copyright or privileged material. If you are not
>>> the
>>>> intended recipient, you may not forward the email or disclose or use
>> the
>>>> information contained in it. If you have received this email message
>> in
>>>> error, please advise the sender immediately by replying to this email
>>> and
>>>> delete the message and any associated attachments. Any views,
>> opinions,
>>>> conclusions, advice or statements expressed in this email message are
>>>> those of the individual sender and should not be relied upon as the
>>>> considered view, opinion, conclusions, advice or statement of this
>>> company
>>>> except where the sender expressly, and with authority, states them to
>> be
>>>> the considered view, opinion, conclusions, advice or statement of this
>>>> company. Every care is taken but we recommend that you scan any
>>>> attachments for viruses.
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>>>>
>>>> **
>>>>
>>>> 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.
>>>> **
>>>>
>>>
>>>
>>>
>>> **
>>>
>>> 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.
>>> **
>>>
>>
>>
>>
>> **
>>
>> 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.
>> **
>
>
>
>
> **
>
> 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.
> **
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Application Scope
Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
It is not a limitation of wicket but J2EE specification.
On Tue, May 6, 2014 at 3:52 PM, Richard W. Adams <RW...@up.com> wrote:
> I assume that means we can't store non-serializable objects in the
> session? This is sounding like a serious deficiency in Wicket's
> architecture...
>
>
>
>
> From: Francois Meillet <fr...@gmail.com>
> To: users@wicket.apache.org
> Date: 05/06/2014 08:48 AM
> Subject: Re: Application Scope
>
>
>
> sessions are serialised
>
> François Meillet
> Formation Wicket - Développement Wicket
>
>
>
>
>
> Le 6 mai 2014 à 15:28, Richard W. Adams <RW...@UP.COM> a écrit :
>
> > One more question: Since each task is associated with a single user,
> would
> > it make more sense to create a task map in Session scope? Or will Wicket
>
> > try to serialize a map we put into the session?
> >
> >
> >
> >
> > From: Martin Grigorov <mg...@apache.org>
> > To: "users@wicket.apache.org" <us...@wicket.apache.org>
> > Date: 05/06/2014 08:06 AM
> > Subject: Re: Application Scope
> >
> >
> >
> > Please don't change the thread subject for all your answers. This
> confuses
> > the threading support in some mail clients.
> >
> > I meant *My*Application, i.e. *Your*Application.
> > Add this method and map/associate all tasks that your run to some
> id/key.
> > Serialize the key and later get a reference to the FutureTask with
> > something like:
> > YourApp.get().getTasks().get(theKey).isDone()/.isCanceled()/...
> >
> > Martin Grigorov
> > Wicket Training and Consulting
> >
> >
> > On Tue, May 6, 2014 at 2:50 PM, Richard W. Adams <RW...@up.com>
> wrote:
> >
> >> Are you referring to org.apache.wicket.Application? I don't see a
> >> getTasksMap() method there. We use Wicket 1.4.17 & our company will
> not
> >> allow us to upgrade to newer versions). If getTasksMap() is unavailable
>
> > in
> >> 1.4.17, could Application.getSharedResources() be used in a similar
> way?
> >>
> >>
> >>
> >>
> >> From: Martin Grigorov <mg...@apache.org>
> >> To: "users@wicket.apache.org" <us...@wicket.apache.org>
> >> Date: 05/06/2014 07:26 AM
> >> Subject: Re: Background Threading
> >>
> >>
> >>
> >> Hi,
> >>
> >> You can put the tasks in an application scoped structure (e.g.
> >> MyApplication.get().getTasksMap()) and use a serializable key.
> >>
> >> Martin Grigorov
> >> Wicket Training and Consulting
> >>
> >>
> >> On Tue, May 6, 2014 at 2:11 PM, Richard W. Adams <RW...@up.com>
> > wrote:
> >>
> >>> Interesting approach. Our use case is more complex, as it runs a
> >>> background task in a separate thread. Our task has three basic
> >>> requirements. It must:
> >>>
> >>> 1. Be cancellable.
> >>>
> >>> 2. Report its outcome (success/failure/warning).
> >>>
> >>> 3. Report incremental progress.
> >>>
> >>> Our fundamental problem is not how to display the progress bar, it's
> > how
> >>> to determine the outcome of the background thread. That's an
> >> unexpectedly
> >>> a tough nut to crack. The vast majority of examples we've seen use the
> >>> Runnable interface (which doesn't help us, as it can't be canceled or
> >>> return a value), rather than Callable interface (which meets our
> > needs,
> >>> but doesn't seem to play well with Wicket)
> >>>
> >>>
> >>>
> >>>
> >>> From: Colin Rogers <Co...@objectconsulting.com.au>
> >>> To: "users@wicket.apache.org" <us...@wicket.apache.org>
> >>> Date: 05/05/2014 08:14 PM
> >>> Subject: RE: Progress Bar
> >>>
> >>>
> >>>
> >>> There is a pretty nifty, jquery based progress bar, in
> > wicket-jquery-ui
> >>> library...
> >>>
> >>>
> >>
> >
> http://www.7thweb.net/wicket-jquery-ui/progressbar/DefaultProgressBarPage
> >>>
> >>> Cheers,
> >>> Col.
> >>>
> >>> -----Original Message-----
> >>> From: Richard W. Adams [mailto:RWADAMS1@UP.COM]
> >>> Sent: Tuesday, 6 May 2014 3:19 AM
> >>> To: users@wicket.apache.org
> >>> Subject: Progress Bar
> >>>
> >>> 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.
> >>>
> >>> 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 & 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.
> >>> **
> >>> EMAIL DISCLAIMER This email message and its attachments are
> > confidential
> >>> and may also contain copyright or privileged material. If you are not
> >> the
> >>> intended recipient, you may not forward the email or disclose or use
> > the
> >>> information contained in it. If you have received this email message
> > in
> >>> error, please advise the sender immediately by replying to this email
> >> and
> >>> delete the message and any associated attachments. Any views,
> > opinions,
> >>> conclusions, advice or statements expressed in this email message are
> >>> those of the individual sender and should not be relied upon as the
> >>> considered view, opinion, conclusions, advice or statement of this
> >> company
> >>> except where the sender expressly, and with authority, states them to
> > be
> >>> the considered view, opinion, conclusions, advice or statement of this
> >>> company. Every care is taken but we recommend that you scan any
> >>> attachments for viruses.
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >>> For additional commands, e-mail: users-help@wicket.apache.org
> >>>
> >>>
> >>>
> >>>
> >>> **
> >>>
> >>> 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.
> >>> **
> >>>
> >>
> >>
> >>
> >> **
> >>
> >> 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.
> >> **
> >>
> >
> >
> >
> > **
> >
> > 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.
> > **
>
>
>
>
> **
>
> 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.
> **
>
--
Regards - Ernesto Reinaldo Barreiro
Re: Application Scope
Posted by Sven Meier <sv...@meiers.net>.
That's a javax.servlet restriction:
http://stackoverflow.com/questions/1662348/setattribute-non-serializable-attribute-java-object-serialization
http://stackoverflow.com/questions/3460249/java-httpsession-setattribute-throws-non-serializable-exception-on-qa-but-not-i
Sven
On 05/06/2014 03:52 PM, Richard W. Adams wrote:
> I assume that means we can't store non-serializable objects in the
> session? This is sounding like a serious deficiency in Wicket's
> architecture...
>
>
>
>
> From: Francois Meillet <fr...@gmail.com>
> To: users@wicket.apache.org
> Date: 05/06/2014 08:48 AM
> Subject: Re: Application Scope
>
>
>
> sessions are serialised
>
> François Meillet
> Formation Wicket - Développement Wicket
>
>
>
>
>
> Le 6 mai 2014 à 15:28, Richard W. Adams <RW...@UP.COM> a écrit :
>
>> One more question: Since each task is associated with a single user,
> would
>> it make more sense to create a task map in Session scope? Or will Wicket
>> try to serialize a map we put into the session?
>>
>>
>>
>>
>> From: Martin Grigorov <mg...@apache.org>
>> To: "users@wicket.apache.org" <us...@wicket.apache.org>
>> Date: 05/06/2014 08:06 AM
>> Subject: Re: Application Scope
>>
>>
>>
>> Please don't change the thread subject for all your answers. This
> confuses
>> the threading support in some mail clients.
>>
>> I meant *My*Application, i.e. *Your*Application.
>> Add this method and map/associate all tasks that your run to some
> id/key.
>> Serialize the key and later get a reference to the FutureTask with
>> something like:
>> YourApp.get().getTasks().get(theKey).isDone()/.isCanceled()/...
>>
>> Martin Grigorov
>> Wicket Training and Consulting
>>
>>
>> On Tue, May 6, 2014 at 2:50 PM, Richard W. Adams <RW...@up.com>
> wrote:
>>> Are you referring to org.apache.wicket.Application? I don't see a
>>> getTasksMap() method there. We use Wicket 1.4.17 & our company will
> not
>>> allow us to upgrade to newer versions). If getTasksMap() is unavailable
>> in
>>> 1.4.17, could Application.getSharedResources() be used in a similar
> way?
>>>
>>>
>>>
>>> From: Martin Grigorov <mg...@apache.org>
>>> To: "users@wicket.apache.org" <us...@wicket.apache.org>
>>> Date: 05/06/2014 07:26 AM
>>> Subject: Re: Background Threading
>>>
>>>
>>>
>>> Hi,
>>>
>>> You can put the tasks in an application scoped structure (e.g.
>>> MyApplication.get().getTasksMap()) and use a serializable key.
>>>
>>> Martin Grigorov
>>> Wicket Training and Consulting
>>>
>>>
>>> On Tue, May 6, 2014 at 2:11 PM, Richard W. Adams <RW...@up.com>
>> wrote:
>>>> Interesting approach. Our use case is more complex, as it runs a
>>>> background task in a separate thread. Our task has three basic
>>>> requirements. It must:
>>>>
>>>> 1. Be cancellable.
>>>>
>>>> 2. Report its outcome (success/failure/warning).
>>>>
>>>> 3. Report incremental progress.
>>>>
>>>> Our fundamental problem is not how to display the progress bar, it's
>> how
>>>> to determine the outcome of the background thread. That's an
>>> unexpectedly
>>>> a tough nut to crack. The vast majority of examples we've seen use the
>>>> Runnable interface (which doesn't help us, as it can't be canceled or
>>>> return a value), rather than Callable interface (which meets our
>> needs,
>>>> but doesn't seem to play well with Wicket)
>>>>
>>>>
>>>>
>>>>
>>>> From: Colin Rogers <Co...@objectconsulting.com.au>
>>>> To: "users@wicket.apache.org" <us...@wicket.apache.org>
>>>> Date: 05/05/2014 08:14 PM
>>>> Subject: RE: Progress Bar
>>>>
>>>>
>>>>
>>>> There is a pretty nifty, jquery based progress bar, in
>> wicket-jquery-ui
>>>> library...
>>>>
>>>>
> http://www.7thweb.net/wicket-jquery-ui/progressbar/DefaultProgressBarPage
>>>> Cheers,
>>>> Col.
>>>>
>>>> -----Original Message-----
>>>> From: Richard W. Adams [mailto:RWADAMS1@UP.COM]
>>>> Sent: Tuesday, 6 May 2014 3:19 AM
>>>> To: users@wicket.apache.org
>>>> Subject: Progress Bar
>>>>
>>>> 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.
>>>>
>>>> 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 & 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.
>>>> **
>>>> EMAIL DISCLAIMER This email message and its attachments are
>> confidential
>>>> and may also contain copyright or privileged material. If you are not
>>> the
>>>> intended recipient, you may not forward the email or disclose or use
>> the
>>>> information contained in it. If you have received this email message
>> in
>>>> error, please advise the sender immediately by replying to this email
>>> and
>>>> delete the message and any associated attachments. Any views,
>> opinions,
>>>> conclusions, advice or statements expressed in this email message are
>>>> those of the individual sender and should not be relied upon as the
>>>> considered view, opinion, conclusions, advice or statement of this
>>> company
>>>> except where the sender expressly, and with authority, states them to
>> be
>>>> the considered view, opinion, conclusions, advice or statement of this
>>>> company. Every care is taken but we recommend that you scan any
>>>> attachments for viruses.
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>>>>
>>>> **
>>>>
>>>> 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.
>>>> **
>>>>
>>>
>>>
>>> **
>>>
>>> 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.
>>> **
>>>
>>
>>
>> **
>>
>> 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.
>> **
>
>
>
> **
>
> 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.
> **
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Application Scope
Posted by "Richard W. Adams" <RW...@UP.COM>.
I assume that means we can't store non-serializable objects in the
session? This is sounding like a serious deficiency in Wicket's
architecture...
From: Francois Meillet <fr...@gmail.com>
To: users@wicket.apache.org
Date: 05/06/2014 08:48 AM
Subject: Re: Application Scope
sessions are serialised
François Meillet
Formation Wicket - Développement Wicket
Le 6 mai 2014 à 15:28, Richard W. Adams <RW...@UP.COM> a écrit :
> One more question: Since each task is associated with a single user,
would
> it make more sense to create a task map in Session scope? Or will Wicket
> try to serialize a map we put into the session?
>
>
>
>
> From: Martin Grigorov <mg...@apache.org>
> To: "users@wicket.apache.org" <us...@wicket.apache.org>
> Date: 05/06/2014 08:06 AM
> Subject: Re: Application Scope
>
>
>
> Please don't change the thread subject for all your answers. This
confuses
> the threading support in some mail clients.
>
> I meant *My*Application, i.e. *Your*Application.
> Add this method and map/associate all tasks that your run to some
id/key.
> Serialize the key and later get a reference to the FutureTask with
> something like:
> YourApp.get().getTasks().get(theKey).isDone()/.isCanceled()/...
>
> Martin Grigorov
> Wicket Training and Consulting
>
>
> On Tue, May 6, 2014 at 2:50 PM, Richard W. Adams <RW...@up.com>
wrote:
>
>> Are you referring to org.apache.wicket.Application? I don't see a
>> getTasksMap() method there. We use Wicket 1.4.17 & our company will
not
>> allow us to upgrade to newer versions). If getTasksMap() is unavailable
> in
>> 1.4.17, could Application.getSharedResources() be used in a similar
way?
>>
>>
>>
>>
>> From: Martin Grigorov <mg...@apache.org>
>> To: "users@wicket.apache.org" <us...@wicket.apache.org>
>> Date: 05/06/2014 07:26 AM
>> Subject: Re: Background Threading
>>
>>
>>
>> Hi,
>>
>> You can put the tasks in an application scoped structure (e.g.
>> MyApplication.get().getTasksMap()) and use a serializable key.
>>
>> Martin Grigorov
>> Wicket Training and Consulting
>>
>>
>> On Tue, May 6, 2014 at 2:11 PM, Richard W. Adams <RW...@up.com>
> wrote:
>>
>>> Interesting approach. Our use case is more complex, as it runs a
>>> background task in a separate thread. Our task has three basic
>>> requirements. It must:
>>>
>>> 1. Be cancellable.
>>>
>>> 2. Report its outcome (success/failure/warning).
>>>
>>> 3. Report incremental progress.
>>>
>>> Our fundamental problem is not how to display the progress bar, it's
> how
>>> to determine the outcome of the background thread. That's an
>> unexpectedly
>>> a tough nut to crack. The vast majority of examples we've seen use the
>>> Runnable interface (which doesn't help us, as it can't be canceled or
>>> return a value), rather than Callable interface (which meets our
> needs,
>>> but doesn't seem to play well with Wicket)
>>>
>>>
>>>
>>>
>>> From: Colin Rogers <Co...@objectconsulting.com.au>
>>> To: "users@wicket.apache.org" <us...@wicket.apache.org>
>>> Date: 05/05/2014 08:14 PM
>>> Subject: RE: Progress Bar
>>>
>>>
>>>
>>> There is a pretty nifty, jquery based progress bar, in
> wicket-jquery-ui
>>> library...
>>>
>>>
>>
>
http://www.7thweb.net/wicket-jquery-ui/progressbar/DefaultProgressBarPage
>>>
>>> Cheers,
>>> Col.
>>>
>>> -----Original Message-----
>>> From: Richard W. Adams [mailto:RWADAMS1@UP.COM]
>>> Sent: Tuesday, 6 May 2014 3:19 AM
>>> To: users@wicket.apache.org
>>> Subject: Progress Bar
>>>
>>> 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.
>>>
>>> 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 & 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.
>>> **
>>> EMAIL DISCLAIMER This email message and its attachments are
> confidential
>>> and may also contain copyright or privileged material. If you are not
>> the
>>> intended recipient, you may not forward the email or disclose or use
> the
>>> information contained in it. If you have received this email message
> in
>>> error, please advise the sender immediately by replying to this email
>> and
>>> delete the message and any associated attachments. Any views,
> opinions,
>>> conclusions, advice or statements expressed in this email message are
>>> those of the individual sender and should not be relied upon as the
>>> considered view, opinion, conclusions, advice or statement of this
>> company
>>> except where the sender expressly, and with authority, states them to
> be
>>> the considered view, opinion, conclusions, advice or statement of this
>>> company. Every care is taken but we recommend that you scan any
>>> attachments for viruses.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>>
>>> **
>>>
>>> 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.
>>> **
>>>
>>
>>
>>
>> **
>>
>> 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.
>> **
>>
>
>
>
> **
>
> 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.
> **
**
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.
**
Re: Application Scope
Posted by Francois Meillet <fr...@gmail.com>.
sessions are serialised
François Meillet
Formation Wicket - Développement Wicket
Le 6 mai 2014 à 15:28, Richard W. Adams <RW...@UP.COM> a écrit :
> One more question: Since each task is associated with a single user, would
> it make more sense to create a task map in Session scope? Or will Wicket
> try to serialize a map we put into the session?
>
>
>
>
> From: Martin Grigorov <mg...@apache.org>
> To: "users@wicket.apache.org" <us...@wicket.apache.org>
> Date: 05/06/2014 08:06 AM
> Subject: Re: Application Scope
>
>
>
> Please don't change the thread subject for all your answers. This confuses
> the threading support in some mail clients.
>
> I meant *My*Application, i.e. *Your*Application.
> Add this method and map/associate all tasks that your run to some id/key.
> Serialize the key and later get a reference to the FutureTask with
> something like:
> YourApp.get().getTasks().get(theKey).isDone()/.isCanceled()/...
>
> Martin Grigorov
> Wicket Training and Consulting
>
>
> On Tue, May 6, 2014 at 2:50 PM, Richard W. Adams <RW...@up.com> wrote:
>
>> Are you referring to org.apache.wicket.Application? I don't see a
>> getTasksMap() method there. We use Wicket 1.4.17 & our company will not
>> allow us to upgrade to newer versions). If getTasksMap() is unavailable
> in
>> 1.4.17, could Application.getSharedResources() be used in a similar way?
>>
>>
>>
>>
>> From: Martin Grigorov <mg...@apache.org>
>> To: "users@wicket.apache.org" <us...@wicket.apache.org>
>> Date: 05/06/2014 07:26 AM
>> Subject: Re: Background Threading
>>
>>
>>
>> Hi,
>>
>> You can put the tasks in an application scoped structure (e.g.
>> MyApplication.get().getTasksMap()) and use a serializable key.
>>
>> Martin Grigorov
>> Wicket Training and Consulting
>>
>>
>> On Tue, May 6, 2014 at 2:11 PM, Richard W. Adams <RW...@up.com>
> wrote:
>>
>>> Interesting approach. Our use case is more complex, as it runs a
>>> background task in a separate thread. Our task has three basic
>>> requirements. It must:
>>>
>>> 1. Be cancellable.
>>>
>>> 2. Report its outcome (success/failure/warning).
>>>
>>> 3. Report incremental progress.
>>>
>>> Our fundamental problem is not how to display the progress bar, it's
> how
>>> to determine the outcome of the background thread. That's an
>> unexpectedly
>>> a tough nut to crack. The vast majority of examples we've seen use the
>>> Runnable interface (which doesn't help us, as it can't be canceled or
>>> return a value), rather than Callable interface (which meets our
> needs,
>>> but doesn't seem to play well with Wicket)
>>>
>>>
>>>
>>>
>>> From: Colin Rogers <Co...@objectconsulting.com.au>
>>> To: "users@wicket.apache.org" <us...@wicket.apache.org>
>>> Date: 05/05/2014 08:14 PM
>>> Subject: RE: Progress Bar
>>>
>>>
>>>
>>> There is a pretty nifty, jquery based progress bar, in
> wicket-jquery-ui
>>> library...
>>>
>>>
>>
> http://www.7thweb.net/wicket-jquery-ui/progressbar/DefaultProgressBarPage
>>>
>>> Cheers,
>>> Col.
>>>
>>> -----Original Message-----
>>> From: Richard W. Adams [mailto:RWADAMS1@UP.COM]
>>> Sent: Tuesday, 6 May 2014 3:19 AM
>>> To: users@wicket.apache.org
>>> Subject: Progress Bar
>>>
>>> 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.
>>>
>>> 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 & 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.
>>> **
>>> EMAIL DISCLAIMER This email message and its attachments are
> confidential
>>> and may also contain copyright or privileged material. If you are not
>> the
>>> intended recipient, you may not forward the email or disclose or use
> the
>>> information contained in it. If you have received this email message
> in
>>> error, please advise the sender immediately by replying to this email
>> and
>>> delete the message and any associated attachments. Any views,
> opinions,
>>> conclusions, advice or statements expressed in this email message are
>>> those of the individual sender and should not be relied upon as the
>>> considered view, opinion, conclusions, advice or statement of this
>> company
>>> except where the sender expressly, and with authority, states them to
> be
>>> the considered view, opinion, conclusions, advice or statement of this
>>> company. Every care is taken but we recommend that you scan any
>>> attachments for viruses.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>>
>>> **
>>>
>>> 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.
>>> **
>>>
>>
>>
>>
>> **
>>
>> 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.
>> **
>>
>
>
>
> **
>
> 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.
> **
Re: Application Scope
Posted by "Richard W. Adams" <RW...@UP.COM>.
One more question: Since each task is associated with a single user, would
it make more sense to create a task map in Session scope? Or will Wicket
try to serialize a map we put into the session?
From: Martin Grigorov <mg...@apache.org>
To: "users@wicket.apache.org" <us...@wicket.apache.org>
Date: 05/06/2014 08:06 AM
Subject: Re: Application Scope
Please don't change the thread subject for all your answers. This confuses
the threading support in some mail clients.
I meant *My*Application, i.e. *Your*Application.
Add this method and map/associate all tasks that your run to some id/key.
Serialize the key and later get a reference to the FutureTask with
something like:
YourApp.get().getTasks().get(theKey).isDone()/.isCanceled()/...
Martin Grigorov
Wicket Training and Consulting
On Tue, May 6, 2014 at 2:50 PM, Richard W. Adams <RW...@up.com> wrote:
> Are you referring to org.apache.wicket.Application? I don't see a
> getTasksMap() method there. We use Wicket 1.4.17 & our company will not
> allow us to upgrade to newer versions). If getTasksMap() is unavailable
in
> 1.4.17, could Application.getSharedResources() be used in a similar way?
>
>
>
>
> From: Martin Grigorov <mg...@apache.org>
> To: "users@wicket.apache.org" <us...@wicket.apache.org>
> Date: 05/06/2014 07:26 AM
> Subject: Re: Background Threading
>
>
>
> Hi,
>
> You can put the tasks in an application scoped structure (e.g.
> MyApplication.get().getTasksMap()) and use a serializable key.
>
> Martin Grigorov
> Wicket Training and Consulting
>
>
> On Tue, May 6, 2014 at 2:11 PM, Richard W. Adams <RW...@up.com>
wrote:
>
> > Interesting approach. Our use case is more complex, as it runs a
> > background task in a separate thread. Our task has three basic
> > requirements. It must:
> >
> > 1. Be cancellable.
> >
> > 2. Report its outcome (success/failure/warning).
> >
> > 3. Report incremental progress.
> >
> > Our fundamental problem is not how to display the progress bar, it's
how
> > to determine the outcome of the background thread. That's an
> unexpectedly
> > a tough nut to crack. The vast majority of examples we've seen use the
> > Runnable interface (which doesn't help us, as it can't be canceled or
> > return a value), rather than Callable interface (which meets our
needs,
> > but doesn't seem to play well with Wicket)
> >
> >
> >
> >
> > From: Colin Rogers <Co...@objectconsulting.com.au>
> > To: "users@wicket.apache.org" <us...@wicket.apache.org>
> > Date: 05/05/2014 08:14 PM
> > Subject: RE: Progress Bar
> >
> >
> >
> > There is a pretty nifty, jquery based progress bar, in
wicket-jquery-ui
> > library...
> >
> >
>
http://www.7thweb.net/wicket-jquery-ui/progressbar/DefaultProgressBarPage
> >
> > Cheers,
> > Col.
> >
> > -----Original Message-----
> > From: Richard W. Adams [mailto:RWADAMS1@UP.COM]
> > Sent: Tuesday, 6 May 2014 3:19 AM
> > To: users@wicket.apache.org
> > Subject: Progress Bar
> >
> > 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.
> >
> > 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 & 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.
> > **
> > EMAIL DISCLAIMER This email message and its attachments are
confidential
> > and may also contain copyright or privileged material. If you are not
> the
> > intended recipient, you may not forward the email or disclose or use
the
> > information contained in it. If you have received this email message
in
> > error, please advise the sender immediately by replying to this email
> and
> > delete the message and any associated attachments. Any views,
opinions,
> > conclusions, advice or statements expressed in this email message are
> > those of the individual sender and should not be relied upon as the
> > considered view, opinion, conclusions, advice or statement of this
> company
> > except where the sender expressly, and with authority, states them to
be
> > the considered view, opinion, conclusions, advice or statement of this
> > company. Every care is taken but we recommend that you scan any
> > attachments for viruses.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
> >
> >
> > **
> >
> > 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.
> > **
> >
>
>
>
> **
>
> 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.
> **
>
**
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.
**
Re: Application Scope
Posted by Martin Grigorov <mg...@apache.org>.
Please don't change the thread subject for all your answers. This confuses
the threading support in some mail clients.
I meant *My*Application, i.e. *Your*Application.
Add this method and map/associate all tasks that your run to some id/key.
Serialize the key and later get a reference to the FutureTask with
something like:
YourApp.get().getTasks().get(theKey).isDone()/.isCanceled()/...
Martin Grigorov
Wicket Training and Consulting
On Tue, May 6, 2014 at 2:50 PM, Richard W. Adams <RW...@up.com> wrote:
> Are you referring to org.apache.wicket.Application? I don't see a
> getTasksMap() method there. We use Wicket 1.4.17 & our company will not
> allow us to upgrade to newer versions). If getTasksMap() is unavailable in
> 1.4.17, could Application.getSharedResources() be used in a similar way?
>
>
>
>
> From: Martin Grigorov <mg...@apache.org>
> To: "users@wicket.apache.org" <us...@wicket.apache.org>
> Date: 05/06/2014 07:26 AM
> Subject: Re: Background Threading
>
>
>
> Hi,
>
> You can put the tasks in an application scoped structure (e.g.
> MyApplication.get().getTasksMap()) and use a serializable key.
>
> Martin Grigorov
> Wicket Training and Consulting
>
>
> On Tue, May 6, 2014 at 2:11 PM, Richard W. Adams <RW...@up.com> wrote:
>
> > Interesting approach. Our use case is more complex, as it runs a
> > background task in a separate thread. Our task has three basic
> > requirements. It must:
> >
> > 1. Be cancellable.
> >
> > 2. Report its outcome (success/failure/warning).
> >
> > 3. Report incremental progress.
> >
> > Our fundamental problem is not how to display the progress bar, it's how
> > to determine the outcome of the background thread. That's an
> unexpectedly
> > a tough nut to crack. The vast majority of examples we've seen use the
> > Runnable interface (which doesn't help us, as it can't be canceled or
> > return a value), rather than Callable interface (which meets our needs,
> > but doesn't seem to play well with Wicket)
> >
> >
> >
> >
> > From: Colin Rogers <Co...@objectconsulting.com.au>
> > To: "users@wicket.apache.org" <us...@wicket.apache.org>
> > Date: 05/05/2014 08:14 PM
> > Subject: RE: Progress Bar
> >
> >
> >
> > There is a pretty nifty, jquery based progress bar, in wicket-jquery-ui
> > library...
> >
> >
> http://www.7thweb.net/wicket-jquery-ui/progressbar/DefaultProgressBarPage
> >
> > Cheers,
> > Col.
> >
> > -----Original Message-----
> > From: Richard W. Adams [mailto:RWADAMS1@UP.COM]
> > Sent: Tuesday, 6 May 2014 3:19 AM
> > To: users@wicket.apache.org
> > Subject: Progress Bar
> >
> > 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.
> >
> > 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 & 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.
> > **
> > EMAIL DISCLAIMER This email message and its attachments are confidential
> > and may also contain copyright or privileged material. If you are not
> the
> > intended recipient, you may not forward the email or disclose or use the
> > information contained in it. If you have received this email message in
> > error, please advise the sender immediately by replying to this email
> and
> > delete the message and any associated attachments. Any views, opinions,
> > conclusions, advice or statements expressed in this email message are
> > those of the individual sender and should not be relied upon as the
> > considered view, opinion, conclusions, advice or statement of this
> company
> > except where the sender expressly, and with authority, states them to be
> > the considered view, opinion, conclusions, advice or statement of this
> > company. Every care is taken but we recommend that you scan any
> > attachments for viruses.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
> >
> >
> > **
> >
> > 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.
> > **
> >
>
>
>
> **
>
> 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.
> **
>
Re: Application Scope
Posted by "Richard W. Adams" <RW...@UP.COM>.
The Javadocs for setMetaData() & MetaDataKey are somewhat unclear (to me).
It says the meta data key has to be a singleton. This seems to imply you
can only store only one piece of metadata for a given component (e.g., a
page)? If so, that's not helpful, since I have to to store many
potentially many (similar) pieces of data (read FutureTask) for the same
page in a multi-user environment: That is, one for each user who's running
the background task thread.
This would be much easier if I could store something non-serializeable in
session scope. Storing things in application scope is beginning to sound
like an extremely awkward work around. Can WebSession store things that
are not serializable? I'm guessing not, since WebSession itself implements
Serializable.
From: Francois Meillet <fr...@gmail.com>
To: users@wicket.apache.org
Date: 05/06/2014 08:06 AM
Subject: Re: Application Scope
You can use MyApp.get().setMetaData() and MyApp.get().getMetaData()
François Meillet
Formation Wicket - Développement Wicket
Le 6 mai 2014 à 14:50, Richard W. Adams <RW...@UP.COM> a écrit :
> Are you referring to org.apache.wicket.Application? I don't see a
> getTasksMap() method there. We use Wicket 1.4.17 & our company will not
> allow us to upgrade to newer versions). If getTasksMap() is unavailable
in
> 1.4.17, could Application.getSharedResources() be used in a similar way?
>
>
>
>
> From: Martin Grigorov <mg...@apache.org>
> To: "users@wicket.apache.org" <us...@wicket.apache.org>
> Date: 05/06/2014 07:26 AM
> Subject: Re: Background Threading
>
>
>
> Hi,
>
> You can put the tasks in an application scoped structure (e.g.
> MyApplication.get().getTasksMap()) and use a serializable key.
>
> Martin Grigorov
> Wicket Training and Consulting
>
>
> On Tue, May 6, 2014 at 2:11 PM, Richard W. Adams <RW...@up.com>
wrote:
>
>> Interesting approach. Our use case is more complex, as it runs a
>> background task in a separate thread. Our task has three basic
>> requirements. It must:
>>
>> 1. Be cancellable.
>>
>> 2. Report its outcome (success/failure/warning).
>>
>> 3. Report incremental progress.
>>
>> Our fundamental problem is not how to display the progress bar, it's
how
>> to determine the outcome of the background thread. That's an
> unexpectedly
>> a tough nut to crack. The vast majority of examples we've seen use the
>> Runnable interface (which doesn't help us, as it can't be canceled or
>> return a value), rather than Callable interface (which meets our needs,
>> but doesn't seem to play well with Wicket)
>>
>>
>>
>>
>> From: Colin Rogers <Co...@objectconsulting.com.au>
>> To: "users@wicket.apache.org" <us...@wicket.apache.org>
>> Date: 05/05/2014 08:14 PM
>> Subject: RE: Progress Bar
>>
>>
>>
>> There is a pretty nifty, jquery based progress bar, in wicket-jquery-ui
>> library...
>>
>>
>
http://www.7thweb.net/wicket-jquery-ui/progressbar/DefaultProgressBarPage
>>
>> Cheers,
>> Col.
>>
>> -----Original Message-----
>> From: Richard W. Adams [mailto:RWADAMS1@UP.COM]
>> Sent: Tuesday, 6 May 2014 3:19 AM
>> To: users@wicket.apache.org
>> Subject: Progress Bar
>>
>> 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.
>>
>> 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 & 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.
>> **
>> EMAIL DISCLAIMER This email message and its attachments are
confidential
>> and may also contain copyright or privileged material. If you are not
> the
>> intended recipient, you may not forward the email or disclose or use
the
>> information contained in it. If you have received this email message in
>> error, please advise the sender immediately by replying to this email
> and
>> delete the message and any associated attachments. Any views, opinions,
>> conclusions, advice or statements expressed in this email message are
>> those of the individual sender and should not be relied upon as the
>> considered view, opinion, conclusions, advice or statement of this
> company
>> except where the sender expressly, and with authority, states them to
be
>> the considered view, opinion, conclusions, advice or statement of this
>> company. Every care is taken but we recommend that you scan any
>> attachments for viruses.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>>
>> **
>>
>> 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.
>> **
>>
>
>
>
> **
>
> 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.
> **
**
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.
**
Re: Application Scope
Posted by Francois Meillet <fr...@gmail.com>.
You can use MyApp.get().setMetaData() and MyApp.get().getMetaData()
François Meillet
Formation Wicket - Développement Wicket
Le 6 mai 2014 à 14:50, Richard W. Adams <RW...@UP.COM> a écrit :
> Are you referring to org.apache.wicket.Application? I don't see a
> getTasksMap() method there. We use Wicket 1.4.17 & our company will not
> allow us to upgrade to newer versions). If getTasksMap() is unavailable in
> 1.4.17, could Application.getSharedResources() be used in a similar way?
>
>
>
>
> From: Martin Grigorov <mg...@apache.org>
> To: "users@wicket.apache.org" <us...@wicket.apache.org>
> Date: 05/06/2014 07:26 AM
> Subject: Re: Background Threading
>
>
>
> Hi,
>
> You can put the tasks in an application scoped structure (e.g.
> MyApplication.get().getTasksMap()) and use a serializable key.
>
> Martin Grigorov
> Wicket Training and Consulting
>
>
> On Tue, May 6, 2014 at 2:11 PM, Richard W. Adams <RW...@up.com> wrote:
>
>> Interesting approach. Our use case is more complex, as it runs a
>> background task in a separate thread. Our task has three basic
>> requirements. It must:
>>
>> 1. Be cancellable.
>>
>> 2. Report its outcome (success/failure/warning).
>>
>> 3. Report incremental progress.
>>
>> Our fundamental problem is not how to display the progress bar, it's how
>> to determine the outcome of the background thread. That's an
> unexpectedly
>> a tough nut to crack. The vast majority of examples we've seen use the
>> Runnable interface (which doesn't help us, as it can't be canceled or
>> return a value), rather than Callable interface (which meets our needs,
>> but doesn't seem to play well with Wicket)
>>
>>
>>
>>
>> From: Colin Rogers <Co...@objectconsulting.com.au>
>> To: "users@wicket.apache.org" <us...@wicket.apache.org>
>> Date: 05/05/2014 08:14 PM
>> Subject: RE: Progress Bar
>>
>>
>>
>> There is a pretty nifty, jquery based progress bar, in wicket-jquery-ui
>> library...
>>
>>
> http://www.7thweb.net/wicket-jquery-ui/progressbar/DefaultProgressBarPage
>>
>> Cheers,
>> Col.
>>
>> -----Original Message-----
>> From: Richard W. Adams [mailto:RWADAMS1@UP.COM]
>> Sent: Tuesday, 6 May 2014 3:19 AM
>> To: users@wicket.apache.org
>> Subject: Progress Bar
>>
>> 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.
>>
>> 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 & 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.
>> **
>> EMAIL DISCLAIMER This email message and its attachments are confidential
>> and may also contain copyright or privileged material. If you are not
> the
>> intended recipient, you may not forward the email or disclose or use the
>> information contained in it. If you have received this email message in
>> error, please advise the sender immediately by replying to this email
> and
>> delete the message and any associated attachments. Any views, opinions,
>> conclusions, advice or statements expressed in this email message are
>> those of the individual sender and should not be relied upon as the
>> considered view, opinion, conclusions, advice or statement of this
> company
>> except where the sender expressly, and with authority, states them to be
>> the considered view, opinion, conclusions, advice or statement of this
>> company. Every care is taken but we recommend that you scan any
>> attachments for viruses.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>>
>> **
>>
>> 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.
>> **
>>
>
>
>
> **
>
> 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.
> **
Application Scope
Posted by "Richard W. Adams" <RW...@UP.COM>.
Are you referring to org.apache.wicket.Application? I don't see a
getTasksMap() method there. We use Wicket 1.4.17 & our company will not
allow us to upgrade to newer versions). If getTasksMap() is unavailable in
1.4.17, could Application.getSharedResources() be used in a similar way?
From: Martin Grigorov <mg...@apache.org>
To: "users@wicket.apache.org" <us...@wicket.apache.org>
Date: 05/06/2014 07:26 AM
Subject: Re: Background Threading
Hi,
You can put the tasks in an application scoped structure (e.g.
MyApplication.get().getTasksMap()) and use a serializable key.
Martin Grigorov
Wicket Training and Consulting
On Tue, May 6, 2014 at 2:11 PM, Richard W. Adams <RW...@up.com> wrote:
> Interesting approach. Our use case is more complex, as it runs a
> background task in a separate thread. Our task has three basic
> requirements. It must:
>
> 1. Be cancellable.
>
> 2. Report its outcome (success/failure/warning).
>
> 3. Report incremental progress.
>
> Our fundamental problem is not how to display the progress bar, it's how
> to determine the outcome of the background thread. That's an
unexpectedly
> a tough nut to crack. The vast majority of examples we've seen use the
> Runnable interface (which doesn't help us, as it can't be canceled or
> return a value), rather than Callable interface (which meets our needs,
> but doesn't seem to play well with Wicket)
>
>
>
>
> From: Colin Rogers <Co...@objectconsulting.com.au>
> To: "users@wicket.apache.org" <us...@wicket.apache.org>
> Date: 05/05/2014 08:14 PM
> Subject: RE: Progress Bar
>
>
>
> There is a pretty nifty, jquery based progress bar, in wicket-jquery-ui
> library...
>
>
http://www.7thweb.net/wicket-jquery-ui/progressbar/DefaultProgressBarPage
>
> Cheers,
> Col.
>
> -----Original Message-----
> From: Richard W. Adams [mailto:RWADAMS1@UP.COM]
> Sent: Tuesday, 6 May 2014 3:19 AM
> To: users@wicket.apache.org
> Subject: Progress Bar
>
> 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.
>
> 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 & 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.
> **
> EMAIL DISCLAIMER This email message and its attachments are confidential
> and may also contain copyright or privileged material. If you are not
the
> intended recipient, you may not forward the email or disclose or use the
> information contained in it. If you have received this email message in
> error, please advise the sender immediately by replying to this email
and
> delete the message and any associated attachments. Any views, opinions,
> conclusions, advice or statements expressed in this email message are
> those of the individual sender and should not be relied upon as the
> considered view, opinion, conclusions, advice or statement of this
company
> except where the sender expressly, and with authority, states them to be
> the considered view, opinion, conclusions, advice or statement of this
> company. Every care is taken but we recommend that you scan any
> attachments for viruses.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
>
> **
>
> 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.
> **
>
**
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.
**
Re: Background Threading
Posted by Martin Grigorov <mg...@apache.org>.
Hi,
You can put the tasks in an application scoped structure (e.g.
MyApplication.get().getTasksMap()) and use a serializable key.
Martin Grigorov
Wicket Training and Consulting
On Tue, May 6, 2014 at 2:11 PM, Richard W. Adams <RW...@up.com> wrote:
> Interesting approach. Our use case is more complex, as it runs a
> background task in a separate thread. Our task has three basic
> requirements. It must:
>
> 1. Be cancellable.
>
> 2. Report its outcome (success/failure/warning).
>
> 3. Report incremental progress.
>
> Our fundamental problem is not how to display the progress bar, it's how
> to determine the outcome of the background thread. That's an unexpectedly
> a tough nut to crack. The vast majority of examples we've seen use the
> Runnable interface (which doesn't help us, as it can't be canceled or
> return a value), rather than Callable interface (which meets our needs,
> but doesn't seem to play well with Wicket)
>
>
>
>
> From: Colin Rogers <Co...@objectconsulting.com.au>
> To: "users@wicket.apache.org" <us...@wicket.apache.org>
> Date: 05/05/2014 08:14 PM
> Subject: RE: Progress Bar
>
>
>
> There is a pretty nifty, jquery based progress bar, in wicket-jquery-ui
> library...
>
> http://www.7thweb.net/wicket-jquery-ui/progressbar/DefaultProgressBarPage
>
> Cheers,
> Col.
>
> -----Original Message-----
> From: Richard W. Adams [mailto:RWADAMS1@UP.COM]
> Sent: Tuesday, 6 May 2014 3:19 AM
> To: users@wicket.apache.org
> Subject: Progress Bar
>
> 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.
>
> 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 & 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.
> **
> EMAIL DISCLAIMER This email message and its attachments are confidential
> and may also contain copyright or privileged material. If you are not the
> intended recipient, you may not forward the email or disclose or use the
> information contained in it. If you have received this email message in
> error, please advise the sender immediately by replying to this email and
> delete the message and any associated attachments. Any views, opinions,
> conclusions, advice or statements expressed in this email message are
> those of the individual sender and should not be relied upon as the
> considered view, opinion, conclusions, advice or statement of this company
> except where the sender expressly, and with authority, states them to be
> the considered view, opinion, conclusions, advice or statement of this
> company. Every care is taken but we recommend that you scan any
> attachments for viruses.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
>
> **
>
> 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.
> **
>
Re: Background Threading
Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
It does not requiere hibernate... I will build an example... better than
empty talk.
On Tue, May 6, 2014 at 3:59 PM, Richard W. Adams <RW...@up.com> wrote:
> Well for starters, the example seems to require Hibernate (which our
> organization doesn't allow us to use). This correct?
>
> Second, I don't have the flexibility implement a service. I have to send
> Javascript back to the client, and the corporate Javascript framework then
> renders the progress bar.
>
> What is the 'context' class you refer to? Where is it instantiated and
> where is it stored?
>
>
>
>
> From: Ernesto Reinaldo Barreiro <re...@gmail.com>
> To: "users@wicket.apache.org" <us...@wicket.apache.org>
> Date: 05/06/2014 07:52 AM
> Subject: Re: Background Threading
>
>
>
> Hi,
>
>
> On Tue, May 6, 2014 at 2:11 PM, Richard W. Adams <RW...@up.com> wrote:
>
> > Interesting approach. Our use case is more complex, as it runs a
> > background task in a separate thread. Our task has three basic
> > requirements. It must:
> >
> > 1. Be cancellable.
> >
> > 2. Report its outcome (success/failure/warning).
> >
> > 3. Report incremental progress.
> >
> > Our fundamental problem is not how to display the progress bar, it's how
> > to determine the outcome of the background thread. That's an
> unexpectedly
> > a tough nut to crack. The vast majority of examples we've seen use the
> > Runnable interface (which doesn't help us, as it can't be canceled or
> > return a value), rather than Callable interface (which meets our needs,
> > but doesn't seem to play well with Wicket)
> >
>
> Really? Is it that hard?
>
> 1-Create a "context" class to pass information to/from WEB
> threads/background thread.
> 2-Both threads keep a copy of it: so you can report progress, cancel
> generation and so on.
>
> I have implemented something like that ages ago
>
> https://code.google.com/p/antilia/wiki/OSGiPowered
>
>
>
> >
> >
> >
> >
> > From: Colin Rogers <Co...@objectconsulting.com.au>
> > To: "users@wicket.apache.org" <us...@wicket.apache.org>
> > Date: 05/05/2014 08:14 PM
> > Subject: RE: Progress Bar
> >
> >
> >
> > There is a pretty nifty, jquery based progress bar, in wicket-jquery-ui
> > library...
> >
> >
> http://www.7thweb.net/wicket-jquery-ui/progressbar/DefaultProgressBarPage
> >
> > Cheers,
> > Col.
> >
> > -----Original Message-----
> > From: Richard W. Adams [mailto:RWADAMS1@UP.COM]
> > Sent: Tuesday, 6 May 2014 3:19 AM
> > To: users@wicket.apache.org
> > Subject: Progress Bar
> >
> > 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.
> >
> > 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 & 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.
> > **
> > EMAIL DISCLAIMER This email message and its attachments are confidential
> > and may also contain copyright or privileged material. If you are not
> the
> > intended recipient, you may not forward the email or disclose or use the
> > information contained in it. If you have received this email message in
> > error, please advise the sender immediately by replying to this email
> and
> > delete the message and any associated attachments. Any views, opinions,
> > conclusions, advice or statements expressed in this email message are
> > those of the individual sender and should not be relied upon as the
> > considered view, opinion, conclusions, advice or statement of this
> company
> > except where the sender expressly, and with authority, states them to be
> > the considered view, opinion, conclusions, advice or statement of this
> > company. Every care is taken but we recommend that you scan any
> > attachments for viruses.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
> >
> >
> > **
> >
> > 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.
> > **
> >
>
>
>
> --
> Regards - Ernesto Reinaldo Barreiro
>
>
>
> **
>
> 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.
> **
>
--
Regards - Ernesto Reinaldo Barreiro
Re: Background Threading
Posted by "Richard W. Adams" <RW...@UP.COM>.
Well for starters, the example seems to require Hibernate (which our
organization doesn't allow us to use). This correct?
Second, I don't have the flexibility implement a service. I have to send
Javascript back to the client, and the corporate Javascript framework then
renders the progress bar.
What is the 'context' class you refer to? Where is it instantiated and
where is it stored?
From: Ernesto Reinaldo Barreiro <re...@gmail.com>
To: "users@wicket.apache.org" <us...@wicket.apache.org>
Date: 05/06/2014 07:52 AM
Subject: Re: Background Threading
Hi,
On Tue, May 6, 2014 at 2:11 PM, Richard W. Adams <RW...@up.com> wrote:
> Interesting approach. Our use case is more complex, as it runs a
> background task in a separate thread. Our task has three basic
> requirements. It must:
>
> 1. Be cancellable.
>
> 2. Report its outcome (success/failure/warning).
>
> 3. Report incremental progress.
>
> Our fundamental problem is not how to display the progress bar, it's how
> to determine the outcome of the background thread. That's an
unexpectedly
> a tough nut to crack. The vast majority of examples we've seen use the
> Runnable interface (which doesn't help us, as it can't be canceled or
> return a value), rather than Callable interface (which meets our needs,
> but doesn't seem to play well with Wicket)
>
Really? Is it that hard?
1-Create a "context" class to pass information to/from WEB
threads/background thread.
2-Both threads keep a copy of it: so you can report progress, cancel
generation and so on.
I have implemented something like that ages ago
https://code.google.com/p/antilia/wiki/OSGiPowered
>
>
>
>
> From: Colin Rogers <Co...@objectconsulting.com.au>
> To: "users@wicket.apache.org" <us...@wicket.apache.org>
> Date: 05/05/2014 08:14 PM
> Subject: RE: Progress Bar
>
>
>
> There is a pretty nifty, jquery based progress bar, in wicket-jquery-ui
> library...
>
>
http://www.7thweb.net/wicket-jquery-ui/progressbar/DefaultProgressBarPage
>
> Cheers,
> Col.
>
> -----Original Message-----
> From: Richard W. Adams [mailto:RWADAMS1@UP.COM]
> Sent: Tuesday, 6 May 2014 3:19 AM
> To: users@wicket.apache.org
> Subject: Progress Bar
>
> 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.
>
> 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 & 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.
> **
> EMAIL DISCLAIMER This email message and its attachments are confidential
> and may also contain copyright or privileged material. If you are not
the
> intended recipient, you may not forward the email or disclose or use the
> information contained in it. If you have received this email message in
> error, please advise the sender immediately by replying to this email
and
> delete the message and any associated attachments. Any views, opinions,
> conclusions, advice or statements expressed in this email message are
> those of the individual sender and should not be relied upon as the
> considered view, opinion, conclusions, advice or statement of this
company
> except where the sender expressly, and with authority, states them to be
> the considered view, opinion, conclusions, advice or statement of this
> company. Every care is taken but we recommend that you scan any
> attachments for viruses.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
>
> **
>
> 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.
> **
>
--
Regards - Ernesto Reinaldo Barreiro
**
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.
**
Re: Background Threading
Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Hi,
On Tue, May 6, 2014 at 2:11 PM, Richard W. Adams <RW...@up.com> wrote:
> Interesting approach. Our use case is more complex, as it runs a
> background task in a separate thread. Our task has three basic
> requirements. It must:
>
> 1. Be cancellable.
>
> 2. Report its outcome (success/failure/warning).
>
> 3. Report incremental progress.
>
> Our fundamental problem is not how to display the progress bar, it's how
> to determine the outcome of the background thread. That's an unexpectedly
> a tough nut to crack. The vast majority of examples we've seen use the
> Runnable interface (which doesn't help us, as it can't be canceled or
> return a value), rather than Callable interface (which meets our needs,
> but doesn't seem to play well with Wicket)
>
Really? Is it that hard?
1-Create a "context" class to pass information to/from WEB
threads/background thread.
2-Both threads keep a copy of it: so you can report progress, cancel
generation and so on.
I have implemented something like that ages ago
https://code.google.com/p/antilia/wiki/OSGiPowered
>
>
>
>
> From: Colin Rogers <Co...@objectconsulting.com.au>
> To: "users@wicket.apache.org" <us...@wicket.apache.org>
> Date: 05/05/2014 08:14 PM
> Subject: RE: Progress Bar
>
>
>
> There is a pretty nifty, jquery based progress bar, in wicket-jquery-ui
> library...
>
> http://www.7thweb.net/wicket-jquery-ui/progressbar/DefaultProgressBarPage
>
> Cheers,
> Col.
>
> -----Original Message-----
> From: Richard W. Adams [mailto:RWADAMS1@UP.COM]
> Sent: Tuesday, 6 May 2014 3:19 AM
> To: users@wicket.apache.org
> Subject: Progress Bar
>
> 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.
>
> 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 & 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.
> **
> EMAIL DISCLAIMER This email message and its attachments are confidential
> and may also contain copyright or privileged material. If you are not the
> intended recipient, you may not forward the email or disclose or use the
> information contained in it. If you have received this email message in
> error, please advise the sender immediately by replying to this email and
> delete the message and any associated attachments. Any views, opinions,
> conclusions, advice or statements expressed in this email message are
> those of the individual sender and should not be relied upon as the
> considered view, opinion, conclusions, advice or statement of this company
> except where the sender expressly, and with authority, states them to be
> the considered view, opinion, conclusions, advice or statement of this
> company. Every care is taken but we recommend that you scan any
> attachments for viruses.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
>
> **
>
> 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.
> **
>
--
Regards - Ernesto Reinaldo Barreiro
Background Threading
Posted by "Richard W. Adams" <RW...@UP.COM>.
Interesting approach. Our use case is more complex, as it runs a
background task in a separate thread. Our task has three basic
requirements. It must:
1. Be cancellable.
2. Report its outcome (success/failure/warning).
3. Report incremental progress.
Our fundamental problem is not how to display the progress bar, it's how
to determine the outcome of the background thread. That's an unexpectedly
a tough nut to crack. The vast majority of examples we've seen use the
Runnable interface (which doesn't help us, as it can't be canceled or
return a value), rather than Callable interface (which meets our needs,
but doesn't seem to play well with Wicket)
From: Colin Rogers <Co...@objectconsulting.com.au>
To: "users@wicket.apache.org" <us...@wicket.apache.org>
Date: 05/05/2014 08:14 PM
Subject: RE: Progress Bar
There is a pretty nifty, jquery based progress bar, in wicket-jquery-ui
library...
http://www.7thweb.net/wicket-jquery-ui/progressbar/DefaultProgressBarPage
Cheers,
Col.
-----Original Message-----
From: Richard W. Adams [mailto:RWADAMS1@UP.COM]
Sent: Tuesday, 6 May 2014 3:19 AM
To: users@wicket.apache.org
Subject: Progress Bar
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.
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 & 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.
**
EMAIL DISCLAIMER This email message and its attachments are confidential
and may also contain copyright or privileged material. If you are not the
intended recipient, you may not forward the email or disclose or use the
information contained in it. If you have received this email message in
error, please advise the sender immediately by replying to this email and
delete the message and any associated attachments. Any views, opinions,
conclusions, advice or statements expressed in this email message are
those of the individual sender and should not be relied upon as the
considered view, opinion, conclusions, advice or statement of this company
except where the sender expressly, and with authority, states them to be
the considered view, opinion, conclusions, advice or statement of this
company. Every care is taken but we recommend that you scan any
attachments for viruses.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
**
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.
**
RE: Progress Bar
Posted by Colin Rogers <Co...@objectconsulting.com.au>.
There is a pretty nifty, jquery based progress bar, in wicket-jquery-ui library...
http://www.7thweb.net/wicket-jquery-ui/progressbar/DefaultProgressBarPage
Cheers,
Col.
-----Original Message-----
From: Richard W. Adams [mailto:RWADAMS1@UP.COM]
Sent: Tuesday, 6 May 2014 3:19 AM
To: users@wicket.apache.org
Subject: Progress Bar
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.
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 & 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.
**
EMAIL DISCLAIMER This email message and its attachments are confidential and may also contain copyright or privileged material. If you are not the intended recipient, you may not forward the email or disclose or use the information contained in it. If you have received this email message in error, please advise the sender immediately by replying to this email and delete the message and any associated attachments. Any views, opinions, conclusions, advice or statements expressed in this email message are those of the individual sender and should not be relied upon as the considered view, opinion, conclusions, advice or statement of this company except where the sender expressly, and with authority, states them to be the considered view, opinion, conclusions, advice or statement of this company. Every care is taken but we recommend that you scan any attachments for viruses.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org