Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » External UIThread access
External UIThread access [message #128715] Mon, 20 April 2009 09:46 Go to next message
Eclipse UserFriend
Originally posted by: markus.wolf.nmmn.com

Hi,

since we are migrating our application to RWT we have many application
points where it would be nice to trigger some change in the UI from
outside of the normal RWT lifecycle. Is there a way to do so?

Markus Wolf
--
NMMN - New Media Markets & Networks GmbH
Geschäftsführung: Kfm. Michael Schütt
Finanzamt HH-Altona UStID DE 812 699 852 HRB 71102 Hamburg
HypoVereinsbank - BLZ 200 300 00 - Konto-Nr. 156 29 82

http://www.nmmn.com Tel.: +49 40 284 118 -0
Langbehnstrasse 6 Entwicklung: -720
22761 Hamburg Fax: -999
Re: External UIThread access [message #128758 is a reply to message #128715] Mon, 20 April 2009 10:30 Go to previous messageGo to next message
Rüdiger Herrmann is currently offline Rüdiger HerrmannFriend
Messages: 581
Registered: July 2009
Senior Member
Markus,

in RWT the UICallBack mechanism is used to achieve this. Search this
newsgroup for UICallback and/or "server push" and see the JavaDoc on
UICallBack and Display#addAsync/addSync.


HTH
Rüdiger

Markus Wolf wrote:
> Hi,
>
> since we are migrating our application to RWT we have many application
> points where it would be nice to trigger some change in the UI from
> outside of the normal RWT lifecycle. Is there a way to do so?
>
> Markus Wolf
Re: External UIThread access [message #128767 is a reply to message #128715] Mon, 20 April 2009 10:36 Go to previous messageGo to next message
Lukas Dziadkowiec is currently offline Lukas DziadkowiecFriend
Messages: 12
Registered: July 2009
Junior Member
Search the news, there are many threads regarding this issue.

or.
http://wiki.eclipse.org/RAP/FAQ
http://www.devx.com/webdev/Article/36101/1763/page/3
Re: External UIThread access [message #128798 is a reply to message #128758] Mon, 20 April 2009 10:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: markus.wolf.nmmn.com

Hi Rüdiger,

> in RWT the UICallBack mechanism is used to achieve this. Search this
> newsgroup for UICallback and/or "server push" and see the JavaDoc on
> UICallBack and Display#addAsync/addSync.
>
thanks for your hint but I've already tried this but get the exception
below.
To explain it a bit more in detail: Our application opens a browser
widget which display 'old' pages of our application. Inside of this
pages we would like to trigger UI updates. When a request to an old page
occurs we try to access the UI with UICallback.activate(...). And this
fails.

The exception we got:

Caused by: java.lang.IllegalStateException: No context available outside
of the request service lifecycle.
at
org.eclipse.rwt.internal.service.ContextProvider.getContext( ContextProvider.java:108)
[org.eclipse.rap.rwt-1.2.0-SNAPSHOT.jar:na]
at
org.eclipse.rwt.internal.service.ContextProvider.getStateInf o(ContextProvider.java:166)
[org.eclipse.rap.rwt-1.2.0-SNAPSHOT.jar:na]
at
org.eclipse.rwt.SessionSingletonBase.getInstance(SessionSing letonBase.java:84)
[org.eclipse.rap.rwt-1.2.0-SNAPSHOT.jar:na]
at
org.eclipse.rwt.internal.lifecycle.UICallBackServiceHandler$ IdManager.getInstance(UICallBackServiceHandler.java:52)
[org.eclipse.rap.rwt-1.2.0-SNAPSHOT.jar:na]
at
org.eclipse.rwt.internal.lifecycle.UICallBackServiceHandler. activateUICallBacksFor(UICallBackServiceHandler.java:488)
[org.eclipse.rap.rwt-1.2.0-SNAPSHOT.jar:na]
at org.eclipse.rwt.lifecycle.UICallBack.activate(UICallBack.jav a:68)
[org.eclipse.rap.rwt-1.2.0-SNAPSHOT.jar:na]
at
de.nmmn.iscontrol.rwt.ExternalAccess.runInUIThread(ExternalA ccess.java:61)
[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[na:1.6.0_10]
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
[na:1.6.0_10]
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
[na:1.6.0_10]
at java.lang.reflect.Method.invoke(Method.java:597) [na:1.6.0_10]
at com.caucho.quercus.env.JavaMethod.invoke(JavaMethod.java:109 )
[resin-quercus-3.2.0.jar:3.0.15]
... 24 common frames omitted

>
> HTH
> Rüdiger
>
> Markus Wolf wrote:
>> Hi,
>>
>> since we are migrating our application to RWT we have many application
>> points where it would be nice to trigger some change in the UI from
>> outside of the normal RWT lifecycle. Is there a way to do so?
>>
>> Markus Wolf


--
NMMN - New Media Markets & Networks GmbH
Geschäftsführung: Kfm. Michael Schütt
Finanzamt HH-Altona UStID DE 812 699 852 HRB 71102 Hamburg
HypoVereinsbank - BLZ 200 300 00 - Konto-Nr. 156 29 82

http://www.nmmn.com Tel.: +49 40 284 118 -0
Langbehnstrasse 6 Entwicklung: -720
22761 Hamburg Fax: -999
Re: External UIThread access [message #128810 is a reply to message #128798] Mon, 20 April 2009 11:03 Go to previous messageGo to next message
Stefan   is currently offline Stefan Friend
Messages: 316
Registered: July 2009
Senior Member
Hi Markus,

as stated in the JavaDoc of UICallBack#activate() this method must
always be called from within a UIThread. This doesn't seem to be the case.

Regards,
Stefan.
Re: External UIThread access [message #128823 is a reply to message #128810] Mon, 20 April 2009 11:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: markus.wolf.nmmn.com

Hi Stefan,

> as stated in the JavaDoc of UICallBack#activate() this method must
> always be called from within a UIThread. This doesn't seem to be the case.
>
thats right. I changed this now to call UICallback... from the UIThread
but now I'm not sure how to get a reference to the users Display.
Since the trigger is external to RWT we have no direct access to any
widget where we could get a reference from.
From the API I saw that we need to use
UICallback.runNonUIThreadWithFakeContext(..) or dispay.asynchExec(..)
which both require the display.
Can you give me any hint on this? Maybe I could fetch the display from
the session using direct session access from our external script.

Thanks
Markus
--
NMMN - New Media Markets & Networks GmbH
Geschäftsführung: Kfm. Michael Schütt
Finanzamt HH-Altona UStID DE 812 699 852 HRB 71102 Hamburg
HypoVereinsbank - BLZ 200 300 00 - Konto-Nr. 156 29 82

http://www.nmmn.com Tel.: +49 40 284 118 -0
Langbehnstrasse 6 Entwicklung: -720
22761 Hamburg Fax: -999
Re: External UIThread access [message #128837 is a reply to message #128823] Mon, 20 April 2009 11:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: markus.wolf.nmmn.com

Hi,

>> as stated in the JavaDoc of UICallBack#activate() this method must
>> always be called from within a UIThread. This doesn't seem to be the case.
>>
> thats right. I changed this now to call UICallback... from the UIThread
> but now I'm not sure how to get a reference to the users Display.
> Since the trigger is external to RWT we have no direct access to any
> widget where we could get a reference from.
> From the API I saw that we need to use
> UICallback.runNonUIThreadWithFakeContext(..) or dispay.asynchExec(..)
> which both require the display.
> Can you give me any hint on this? Maybe I could fetch the display from
> the session using direct session access from our external script.
>
ok, with fetching the display from the SessionStore using the plain
HttpServletRequest this does work. But it feels a bit ugly since we are
using RWT internal session information.

Thanks for any help
Markus
--
NMMN - New Media Markets & Networks GmbH
Geschäftsführung: Kfm. Michael Schütt
Finanzamt HH-Altona UStID DE 812 699 852 HRB 71102 Hamburg
HypoVereinsbank - BLZ 200 300 00 - Konto-Nr. 156 29 82

http://www.nmmn.com Tel.: +49 40 284 118 -0
Langbehnstrasse 6 Entwicklung: -720
22761 Hamburg Fax: -999
Re: External UIThread access [message #128930 is a reply to message #128823] Mon, 20 April 2009 15:11 Go to previous messageGo to next message
Rüdiger Herrmann is currently offline Rüdiger HerrmannFriend
Messages: 581
Registered: July 2009
Senior Member
Markus Wolf wrote:
> Hi Stefan,
>
>> as stated in the JavaDoc of UICallBack#activate() this method must
>> always be called from within a UIThread. This doesn't seem to be the case.
>>
> thats right. I changed this now to call UICallback... from the UIThread
> but now I'm not sure how to get a reference to the users Display.
> Since the trigger is external to RWT we have no direct access to any
> widget where we could get a reference from.
> From the API I saw that we need to use
> UICallback.runNonUIThreadWithFakeContext(..) or dispay.asynchExec(..)
> which both require the display.
> Can you give me any hint on this? Maybe I could fetch the display from
> the session using direct session access from our external script.
Session and Display have a one-to-one relation in RAP. As long as
you can access the Session (RWT#getSessionStore()) you can also
access the display (Display#getCurrent().

If the background thread is not directly associated to a session
(i.e. is not started from within a session), the code that states
the interest of a session in update notifications would need to pass
in a reference to the display. Be careful to remove the display upon
session invalidation. Otherwise this could cause a memory leak.

>
> Thanks
> Markus
Re: External UIThread access [message #128956 is a reply to message #128930] Mon, 20 April 2009 15:42 Go to previous message
Eclipse UserFriend
Originally posted by: markus.wolf.nmmn.com

Hi Rüdiger,

>>> as stated in the JavaDoc of UICallBack#activate() this method must
>>> always be called from within a UIThread. This doesn't seem to be the
>>> case.
>>>
>> thats right. I changed this now to call UICallback... from the UIThread
>> but now I'm not sure how to get a reference to the users Display.
>> Since the trigger is external to RWT we have no direct access to any
>> widget where we could get a reference from.
>> From the API I saw that we need to use
>> UICallback.runNonUIThreadWithFakeContext(..) or dispay.asynchExec(..)
>> which both require the display.
>> Can you give me any hint on this? Maybe I could fetch the display from
>> the session using direct session access from our external script.
> Session and Display have a one-to-one relation in RAP. As long as you
> can access the Session (RWT#getSessionStore()) you can also access the
> display (Display#getCurrent().
>
> If the background thread is not directly associated to a session (i.e.
> is not started from within a session), the code that states the interest
> of a session in update notifications would need to pass in a reference
> to the display. Be careful to remove the display upon session
> invalidation. Otherwise this could cause a memory leak.
>
I also fetch the SessionStoreImpl directly from the session using the
key under which it is stored in the sesssion.
The http request which should update the UI is handled by a PHP script
and runs in a quercus environment.
As I said, it is a bit ugly but it does work now. :)

Thank you again
Markus
--
NMMN - New Media Markets & Networks GmbH
Geschäftsführung: Kfm. Michael Schütt
Finanzamt HH-Altona UStID DE 812 699 852 HRB 71102 Hamburg
HypoVereinsbank - BLZ 200 300 00 - Konto-Nr. 156 29 82

http://www.nmmn.com Tel.: +49 40 284 118 -0
Langbehnstrasse 6 Entwicklung: -720
22761 Hamburg Fax: -999
Previous Topic:ActionFactory CUT,COPY, PASTE, ABOUT, PRINT Commented out
Next Topic:Session timeout error
Goto Forum:
  


Current Time: Tue Dec 07 17:21:54 GMT 2021

Powered by FUDForum. Page generated in 0.01930 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top