Is there a way to tell server side code from client side code? [message #526806] |
Mon, 12 April 2010 22:55  |
Eclipse User |
|
|
|
Hi Friends,
Could someone tell me how to differentiate server side code from client side code in a RAP project?
I put some code in Application, which is responsible for loading reference data from DB. The data are stored in static HashMaps. My original thought is that these data will be used by different users, but I found it's not. Every time when a new web browser opens the data is accumulated, namely same data is loaded into same HashMaps, that is an error. How could that be?
Is it just that because I use static maps?
|
|
|
Re: Is there a way to tell server side code from client side code? [message #526831 is a reply to message #526806] |
Tue, 13 April 2010 03:39   |
Eclipse User |
|
|
|
Hi Wane,
wayne wrote:
> Hi Friends,
> Could someone tell me how to differentiate server side code from client
> side code in a RAP project?
Server-side code is Java, client-side code is Javascript. None of your
code is ever pushed onto the client, if that's what you mean. You don't
have to deal with client-side code unless you write custom widgets.
> I put some code in Application, which is responsible for loading
> reference data from DB. The data are stored in static HashMaps. My
> original thought is that these data will be used by different users, but
> I found it's not. Every time when a new web browser opens the data is
> accumulated, namely same data is loaded into same HashMaps, that is an
> error. How could that be?
> Is it just that because I use static maps?
Every user gets his own Application instance. If you want to initialize
these HashMaps only once, do it in a static initializer block or use
lazy loading. Note that with lazy loading or if there's any write access
to the maps, you need synchronization.
Best regards, Ralf
|
|
|
|
|
|
Re: Is there a way to tell server side code from client side code? [message #527683 is a reply to message #527663] |
Fri, 16 April 2010 02:38   |
Eclipse User |
|
|
|
Hi,
this is not a RAP issue, actually it is a SWT issue.
http://www.eclipse.org/swt/faq.php#uithread
Greetings,
-ben
Am 16.04.2010 04:46, schrieb wayne:
> By static I mean, if you define a static field in a class, and open a
> web page to access it, and close it, then open another to access it, you
> will be notifiied with an error "invalide thread access". I don't know why.
|
|
|
Re: Is there a way to tell server side code from client side code? [message #528347 is a reply to message #527663] |
Tue, 20 April 2010 04:24  |
Eclipse User |
|
|
|
the "invalid thread access" is thrown by a widget when it is accessed
from any other thread than the UI thread that created it.
A widget is meant to live only in the scope of a session. If you are
holding a static reference to a widget to are effectively sharing it
across multiple sessions. The exception that you receive when accessing
the field from the second session (web page) is correct.
What you are looking for is probably a session-singleton. See the
JavaDoc from SessionSingletonBase.
HTH
Rüdiger
--
Rüdiger Herrmann
http://eclipsesource.com
On 16.04.2010 04:46, wayne wrote:
> By static I mean, if you define a static field in a class, and open a
> web page to access it, and close it, then open another to access it, you
> will be notifiied with an error "invalide thread access". I don't know why.
|
|
|
Powered by
FUDForum. Page generated in 0.45679 seconds