Hi Lance,
Yes what you say is true, however to make the AlertManager compatible
with asynchronous usage (ie the request/response is gone but the session
is still a valid context) the code could simply change from:
if (request.isXHR())
(and removing the Request field)
to
Request request = environment.peek(Request.class);
if (request != null && request.isXHR())
Then there would be no confusion and the best behaviour would happen by
default instead of an exception being thrown.
http://tapestry.apache.org/5.4/apidocs/org/apache/tapestry5/services/Environment.html#peek%28java.lang.Class%29
cheers, p.
On 9/11/2014 5:48 AM, Lance Java wrote:
The Request and Response are PerThread services meaning the service is
actually proxy which passes through to a PerThreadValue. This PerThread
value will be null on a non-request thread.
There's a few approaches to work around this including:
1. Pass values from the request thread to the worker on the parallel thread
(via worker's constructor / anonymous inner class)
2. Return a result (eg an alert) to the request thread and invoke the
PerThread service on the request thread.
On 6 Nov 2014 01:33, "Paul Stanton" <pa...@mapshed.com.au> wrote:
Hi, i'm not sure if this is worth logging as a Jira or if i've missed the
point.. please advise.
I'm adding an alert via alertManager in an inner thread.
void onSomething()
{
final AlertManager fAlerts = alerts;
new Thread()
{
public void run()
{
.... do something longish
fAlerts.info("hi"); // throws ex
}
}
}
The only problem with this is that the check of request.isXhr requires the
request to be on the environment. I'm sure you can peek for the request
prior to testing it (i've done this before) which would then allow the
alertManager to be used asynchronously. in the mean time adding the alert
to AlertStorage instead (bypassing AlertManager) works fine.
does anyone have a good reason why this isn't an issue?
cheers.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org