Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best practice for storing globally required objects in GWT

Tags:

gwt

I am starting to develop a GWT application in MVP style (GWTP) and which uses Spring security for authentication and authorization on server side.

In many views of the application, I have to enable or disable controls with respect to a granted authority of the current user. I already have an RPC service which provides access to a userDetailsDto containing all the necessary information.

Now my question: What is the best place to store the user DTO on client side?

Since the user rights are relevant in many presenters, I would have to pass it around everywhere. Alternatively, I could set an RPC service instance in every presenter and requets the user details each time (probably cached on client-side). But i don't like the idea of having a user RPC service in each presenter just for this purpose.

To be honest, I'd rather would prefer a central registry where to put the UserDetails object and which is accessable from anywhere in my app. Is there already such a registry in GWT?

As in my example, you might often be confronted with horizontally used objects. How to deal with them in GWT?

like image 491
rainer198 Avatar asked Jan 24 '12 14:01

rainer198


1 Answers

Simply store your current user in public static variable. It will be accessible from everywhere.

like image 122
koma Avatar answered Oct 02 '22 06:10

koma