Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » Actions upon user login in Client and Server
Actions upon user login in Client and Server [message #1552665] Thu, 08 January 2015 08:41 Go to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
We have some data that is required both on the client and the server. It is user dependent but stays the same during the whole session of a user. I want to load this on the server after the user has succesfully logged in and afterwards also need this information on the client.

What is the best way to trigger this loading?

Currently I'm doing it in AccessControlService.execLoadPermission() but am not really happy with that as the data I am loading has nothing to do with permissions. Is there another/better convenient method I could hook into for my purpose?

If I want this data to be available during the whole session, I guess the ServerSession would be the place to store this, is this correct?

As I will also need this data on the client side, I was wondering if there was a way to automagically share this data between the client and server sessions? On the Communication Concept page I found something about the SharedContext but apart from the title, there is no information about this. Is this the feature I would want?

Alternatively, I could load the data from the server using a ProcessService and then store it explicitely on the ClientSession. When would the best point to do this be? It would need to be a point in time where it is guaranteed, that the server side execution has run. I was thinking that DesktopExtension.desktopOpenedDelegate() (or if not using the extension Desktop.execOpened()) would be a good place.

Thinking of this, maybe triggering this from the client side is another option instead of using execLoadPermission(). I could call the ProcessService from my DesktopExtension which would load this data and then store it on the server session and return it to the client.

What are the recommended ways of doing this?
Re: Actions upon user login in Client and Server [message #1553093 is a reply to message #1552665] Thu, 08 January 2015 13:50 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
I would fetch the data when the server session is created in: ServerSession.execLoadSession()

If the amount of data is not to big (few values), it make sense to put it in the shared context variable map of the Session you will be able to read it from the client

Here an example with one String value called UserInfo:

@Override
protected void execLoadSession() throws ProcessingException {
  LOG.info("created a new session for " + getUserId());
  String userInfo = .. ; //Do something to initialize the value.
  setUserInfo(userInfo);
}


On the Server Session, you need to provide a getter and a setter like this:
/**
 * @return the userInfo from the shared context
 */
public String getUserInfo() {
  return getSharedContextVariable(USER_INFO, String.class);
}

/**
 * @param userInfo
 *          the userInfo to set into the shared context
 */
public void setUserInfo(String userInfo) {
  setSharedContextVariable(USER_INFO, String.class, userInfo);
}


In the client session you can add the getter:
/**
 * @return the userInfo
 */
public String getUserInfo() {
  return getSharedContextVariable(USER_INFO, String.class);
}

To be correct, the USER_INFO constant should be shared between the client and the server. You can put this on some interface in the shared plugin. If you do not so (like in my case) you have the same constant defined twice.

After this, you can read the user info in the Client Session:
@Override
public void execLoadSession() throws ProcessingException {
  //...
  System.out.println("User Info" + getUserInfo());
}


Or from anywhere in the client:
MessageBox.showOkMessage("Client Session User Info", ClientSession.get().getUserInfo(), null);


I hope it help you to start.

.

[Updated on: Thu, 08 January 2015 13:55]

Report message to a moderator

Re: Actions upon user login in Client and Server [message #1559733 is a reply to message #1553093] Mon, 12 January 2015 06:56 Go to previous message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Thanks a lot Jeremie, this is exactly what I had been looking for.
Previous Topic:TableField as template?
Next Topic:Scout Mars M4 andLookupCalls
Goto Forum:
  


Current Time: Tue Apr 16 05:52:34 GMT 2024

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

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

Back to the top