On Sun, Oct 2, 2011 at 3:06 PM, benneq <benjamin_ma...@lavabit.com> wrote:

>
> A working solution would be:
> have a single presenter and a single view. And the presenter tells the
> display using a boolean which UI to display. But I expect it to
> produce very ugly code. Everywhere:
> # if(loggedIn == true)
> #    show this;
> #
> # show UI for both;
>
>
If you don't mind having the admin widgets/elements exist in all pages, but
be hidden then this, pretty much.

In your view:
showAdminUi(boolean isAdmin) {
   adminButtonA.setVisible(isAdmin);
   adminTextBoxB.setVisible(isAdmin);
   adminButtonY.setVisible(isAdmin);
}

Call it from your presenter. And hide the widgets by default (just call
showAdminUi(false) in your views constructor)
You could further improve this method using CSS and/or searching for the
widgets/elements to be toggled. You can also group things inside Panel's and
just hide/show them.

There are certainly other approaches, but no need to overcomplicate it for a
handful of widgets on each page.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to