Andrey,

RPC is the way I do it. I have a User object that can be passed
between the client and server. It's kept on the client after login so
the entire UI can easily refer to it. My security scheme contains
roles that are a collection of rights. On the server side, at the time
of login, the roles and rights are retrieved from the database for the
user and added to the user object. The user object is only retrieved
from the server once since it is not stored anywhere (other than in
memory) on the client side. When the app is first entered, the user
object won't exist and therefore require a login. On the client side,
the UI can use the existence (or non-existence) of rights to determine
what to display:

if (Controller.getUser().hasRights("viewName")) {
  panel.add(lblName);
}

it can also handle multiple rights in one call like this:

if (Controller.getUser().hasRights("viewThis|viewThat|viewTheOther"))
{
  // do whatever
}

or even logical and's:

if (Controller.getUser().hasRights("viewThis&viewThat")) {
  // do something
}

This has worked out very well for me, but YMMV.

HTH,
Chad

On Jun 23, 10:04 am, ailinykh <[email protected]> wrote:
> Thank you!
> I'm thinking about second solution. It brings up next question- how to
> get user role on client side?
> Right now I see only one way - ask the server through RPC. Does GWT
> provide any session management?
>
> Thank you,
>   Andrey
>
> On Jun 23, 7:34 am, olivier nouguier <[email protected]>
> wrote:
>
>
>
> > 2 solutions:
> > * 2 gwt applications user and admin (you could use a custom
> > properties/permutation).
> > * 1 gwt application and applicative (if(userInRole("admin")) customization.
> > HIH
>
> > On Tue, Jun 23, 2009 at 2:28 PM, ailinykh <[email protected]> wrote:
>
> > > Hello, everybody!
> > > I have a widget (Tab in TabPanel, for example) which is dedicated to
> > > some administrative tasks. Only administrator is supposed to use it. I
> > > don't want to bother everyone by this widget, I want to show it only
> > > if user logged in as Administrator.
> > > What is the best way to implement it?
>
> > > Thnak you,
> > >  Andrey
>
> > --
> >    “There are two ways of constructing a software design: One way is to make
> > it so simple that there are obviously no deficiencies, and the other way is
> > to make it so complicated that there are no obvious deficiencies. The first
> > method is far more difficult.”
>
> >    Sir Charles Anthony Richard Hoare
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to