How to disable menu items?

358 views
Skip to first unread message

Magnus

unread,
Aug 1, 2010, 1:25:36 PM8/1/10
to Google Web Toolkit
Hi,

I have a MenuBar with MenuItems, which I would like to selectively
enable for defined user groups. But how can I enable/disable menu
items?

Thanks
Magnus

Alan Hadsell

unread,
Aug 1, 2010, 4:56:46 PM8/1/10
to Google Web Toolkit
Take a look at gwtlib: http://code.google.com/p/gwtlib/. It has
menubars
and menu items that can be enabled and disabled.

Magnus

unread,
Aug 3, 2010, 10:28:32 AM8/3/10
to Google Web Toolkit
Thank you,

but shouldn't GWT itself provide a mechanism to disable menu items?

Using an additional library is not the problem for me, but using an
additional library because of such a small functionality that should
be present in any menu implementation is a problem for me. As a
consequence I would end up in about a dozent libs...

Isn't there another solution?

Why is this missing?

Thanks
Magnus

Rob Coops

unread,
Aug 3, 2010, 10:42:33 AM8/3/10
to google-we...@googlegroups.com
So what you are saying is that you need a way for the menu to detect which user/user group is looking at the menu.

As you are already saying you have user groups it should not be to hard to inform the menu about the user group that is trying to open it. Once the menu knows which group is trying to open it it can use internal hard coded or externally read logic to decide what fields to render and how to render them, what events to attach to the elements and so on.

I would simply hand the menu a variable/object that identifies the user group accessing it. Then the menu logic can deal with the rest. I would though use an external location to store the logic for the menu so you can easily update it should you need to add a new group in the future.

I hope that helps a bit...



--
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-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.


Alan Hadsell

unread,
Aug 3, 2010, 11:29:42 AM8/3/10
to Google Web Toolkit


On Aug 3, 10:28 am, Magnus <alpineblas...@googlemail.com> wrote:
> Thank you,
>
> but shouldn't GWT itself provide a mechanism to disable menu items?
>
> Using an additional library is not the problem for me, but using an
> additional library because of such a small functionality that should
> be present in any menu implementation is a problem for me. As a
> consequence I would end up in about a dozent libs...
>
> Isn't there another solution?
>
> Why is this missing?
>

See issue 1649: http://code.google.com/p/google-web-toolkit/issues/detail?id=1649
. As you can see, it's an "accepted" issue, but apparently not high-
enough priority to get fixed yet. Star the issue if it's important to
you.

Magnus

unread,
Aug 4, 2010, 1:42:48 AM8/4/10
to Google Web Toolkit
Hi Rob,

I think you got me a little bit wrong: I don't want the menu to handle
the logic. I can handle the logic my self. But I need to tell the menu
that it should show (paint) a menu item as disabled.

Give me a method like this and I am happy:

MenuItem.setEnabled (boolean enabled);

Well, the recommendation for gwtlib from Alan shows that this must be
implemented already. Then it must also be possible for me to do this
"by hand", without using an additional library. But how?

It would be fine if someone could tell how this can be done.

Thanks
Magnus



On Aug 3, 4:42 pm, Rob Coops <rco...@gmail.com> wrote:
> So what you are saying is that you need a way for the menu to detect which
> user/user group is looking at the menu.
>
> As you are already saying you have user groups it should not be to hard to
> inform the menu about the user group that is trying to open it. Once the
> menu knows which group is trying to open it it can use internal hard
> coded or externally read logic to decide what fields to render and how to
> render them, what events to attach to the elements and so on.
>
> I would simply hand the menu a variable/object that identifies the user
> group accessing it. Then the menu logic can deal with the rest. I would
> though use an external location to store the logic for the menu so you can
> easily update it should you need to add a new group in the future.
>
> I hope that helps a bit...
>
> > google-web-tool...@googlegroups.com<google-web-toolkit%2Bunsu...@googlegroups.com>
> > .

Alan Hadsell

unread,
Aug 4, 2010, 10:53:51 AM8/4/10
to Google Web Toolkit


On Aug 4, 1:42 am, Magnus <alpineblas...@googlemail.com> wrote:
>
> It would be fine if someone could tell how this can be done.
>

LMGTFY: http://code.google.com/p/gwtlib/source/browse/#svn/trunk/src/org/gwtlib/client/menu/ui

Take a look at the gwtlib source code for the MenuBar and MenuItem
classes, which are derived from the corresponding GWT classes. All
will be revealed!

Magnus

unread,
Aug 4, 2010, 10:48:24 PM8/4/10
to Google Web Toolkit
Hi Alan,

I see, the disabled menu item is realized with CSS!

But I have still a question: The GWT library uses CSS styles beginning
with "gwt-". The standard styles for the GWT widgets also begin with
"gwt" and are defined in "standard.css". How is the mechanism when
extending the standard styles? My experience is that own styles are
overwritten by standard.css.

Thanks
Magnus

On Aug 4, 4:53 pm, Alan Hadsell <ahads...@gmail.com> wrote:
> On Aug 4, 1:42 am, Magnus <alpineblas...@googlemail.com> wrote:
>
>
>
> > It would be fine if someone could tell how this can be done.
>
> LMGTFY:http://code.google.com/p/gwtlib/source/browse/#svn/trunk/src/org/gwtl...

Alan Hadsell

unread,
Aug 5, 2010, 10:42:20 AM8/5/10
to Google Web Toolkit


On Aug 4, 10:48 pm, Magnus <alpineblas...@googlemail.com> wrote:


> How is the mechanism when extending the standard styles? My experience is that own styles are overwritten by standard.css.

Take a look at the menu sample app, contained in the gwtlib project.

http://code.google.com/p/gwtlib/source/browse/#svn/trunk/samples/menu

Reply all
Reply to author
Forward
0 new messages