Your code works fine for me with the exception of the ClickHandler you
defined for "item1".  MenuItems don't have click handlers, they have
Command objects (and this is the error I saw in hosted mode).
Commenting out the ClickHandler code is all it took (I also changed
the class name and package so it would fit into my test project, but
that shouldn't impact how it works).  So I guess I'm wondering how you
instantiated your "testMenu" (classes should start with a capital
letter).

smoyer

On May 14, 3:07 am, Robert Quinn <[email protected]> wrote:
> I don't have an editor in front of me, so here's a shot in the dark:
> try putting the nested MenuBar directly under the outer MenuBar
> instead of under a MenuItem.
>
> On May 11, 1:48 am, chakresh <[email protected]> wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > I am trying to create menus using UiBinder.
>
> > my ui.xml goes like
>
> > <!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent";>
> > <ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
> >     xmlns:g='urn:import:com.google.gwt.user.client.ui'>
>
> >         <g:MenuBar vertical='true' ui:field='mainMenu'>
> >             <g:MenuItem ui:field='item1'>Item 1</g:MenuItem>
> >             <g:MenuItem ui:field='item2'>Item 2</g:MenuItem>
> >             <g:MenuItem ui:field='sub' enabled='false'>
> >                 Submenu
> >                 <g:MenuBar vertical='true' ui:field='subMenu' />
> >             </g:MenuItem>
> >         </g:MenuBar>
> > </ui:UiBinder>
>
> > and java file goes like
> > package com.cadence.ams.client.ui;
>
> > import com.google.gwt.core.client.GWT;
> > import com.google.gwt.event.dom.client.ClickEvent;
> > import com.google.gwt.uibinder.client.UiBinder;
> > import com.google.gwt.uibinder.client.UiField;
> > import com.google.gwt.uibinder.client.UiHandler;
> > import com.google.gwt.user.client.Window;
> > import com.google.gwt.user.client.ui.Composite;
> > import com.google.gwt.user.client.ui.HasText;
> > import com.google.gwt.user.client.ui.Widget;
> > import com.google.gwt.user.client.ui.MenuBar;
> > import com.google.gwt.user.client.ui.MenuItem;
>
> > public class testMenu extends Composite {
>
> >         private static testMenuUiBinder uiBinder = GWT
> >                         .create(testMenuUiBinder.class);
>
> >         interface testMenuUiBinder extends UiBinder<Widget, testMenu> {
> >         }
>
> >         public testMenu() {
> >                 initWidget(uiBinder.createAndBindUi(this));
> >         }
>
> >         @UiField MenuBar mainMenu;
> >         @UiField MenuItem item1;
> >         @UiField MenuItem item2;
> >         @UiField MenuBar subMenu;
> >         @UiField MenuItem sub;
>
> >         @UiHandler("item1")
> >         void onClick(ClickEvent e) {
> >                 Window.alert("item1!");
> >         }
>
> > }
>
> > And while compiling I am getting error.
> > [ERROR] The prefix "g" for element "g:MenuBar" is not bound.
> > [ERROR] Error parsing XML (line 1): The prefix "g" for element
> > "g:MenuBar" is not bound.
>
> > I searched for internet and google group but could not get the
> > solution.
> > I am very new to GWT, in case of any stupid mistake also do let me
> > know.
>
> > Help will be very much appreciated.
> > Thanks,
> > Chakresh

-- 
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