If I understand you correctly, you want to know how to provide a
reference to your menu object for the use of the composite widget of a
given page.

If that is correct, then there is more than one way to do this.

The simplest approach would be to retain a reference to your Menu
object on a variable when your create it and then pass that reference
to your Composite-derived class in its constructor or other set...()
method.

Another approach would be to derive a class MyMenu from Menu and then
implement the singleton pattern for that derived class.  You could
then attach an instance of MyMenu to RootPanel instead of Menu.  By
using the singleton pattern, there will never be more than one MyMenu
object, and so you should be able to obtain a reference to that unique
object from a static method such as MyMenu.getInstance().  That static
method can then be invoked from your composite to obtain your
reference.

You could also incorporate your menu as an element of your Composite-
derived class.

You could, I suppose, use RootPanel.get().getWidget(index) to obtain
the menu, but that would be a rather brittle approach.
Only slightly better would be to create an HTML element with an ID
like "MenuLocation" and then use RootPanel.get("MenuLocation").add(new
Menu) to add your Menu and then use RootPanel.get
("MenuLocation").getWidget(index) to retrieve a reference to it.

The bottom line is that a reference to a widget can be stored and
retrieved in the same manner as any other variable.  You do not have
to go through the RootPanel in order to find it.

Hopefully, I have not misunderstood the question, thereby providing
information of which you were already aware.

Carl


On Jul 30, 1:56 am, Sherkan <[email protected]> wrote:
> Hi,
> I'm nebie in GWT.
>
> I've created simple project:
> -one standalone entry point with main menu which is on each page
> rendered, and couple standalone composites each one for "sub page".
>
> So far so good:)
> In main menu, I've got ToolBarMenu button, which I want to change from
> loaded composite.
> How can I do it, or how can I get my main menu from composite and
> change some object?
>
> My composite don't create menu object. My page view is created
> directly in RootPanel:
> RootPanel.get().add(new Menu());
> RootPanel.get().add(new AddNewServer());
--~--~---------~--~----~------------~-------~--~----~
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