Skip to main content



      Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Is there a way to tell server side code from client side code?
Is there a way to tell server side code from client side code? [message #526806] Mon, 12 April 2010 22:55 Go to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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 #526850 is a reply to message #526831] Tue, 13 April 2010 05:49 Go to previous messageGo to next message
Eclipse UserFriend
But why "static" is shared by different newly opened web page, not in different session?
Re: Is there a way to tell server side code from client side code? [message #526892 is a reply to message #526850] Tue, 13 April 2010 08:01 Go to previous messageGo to next message
Eclipse UserFriend
wayne wrote:
> But why "static" is shared by different newly opened web page, not in
> different session?

Not sure if I understand your question. A newly opened web page does
result in a new session. Static fields are bound to the class, which is
loaded only once.

If this doesn't answer your question, please describe your problem more
precisely.

Ralf
Re: Is there a way to tell server side code from client side code? [message #527663 is a reply to message #526892] Thu, 15 April 2010 22:46 Go to previous messageGo to next message
Eclipse UserFriend
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 #527683 is a reply to message #527663] Fri, 16 April 2010 02:38 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
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.
Previous Topic:Milestone 6 of RAP 1.3 is now available
Next Topic:Using Draw2d canvas in RAP
Goto Forum:
  


Current Time: Sun Jun 22 20:29:01 EDT 2025

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

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

Back to the top