Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 933889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:54:21+00:00 2026-05-15T20:54:21+00:00

Sorry if it’s a silly question , but I’m just starting learning GWT and

  • 0

Sorry if it’s a silly question , but I’m just starting learning GWT and got stuck to this problem for a long time … .
Here is my code :

public void onModuleLoad() {

    HelloWorldPanel helloWorldPanel = new HelloWorldPanel();
    RootPanel.get().add(helloWorldPanel);
    //RootPanel.getBodyElement().appendChild(helloWorldPanel.getElement());

    Button b = new Button();
    b.setText("button B");
    b.addClickHandler(new ClickHandler()
    {
      @Override
      public void onClick(ClickEvent arg0)
      {
        System.out.println("click B");
        Window.alert("Hello button B");
      }
    });
    RootPanel.get().add(b);
}

And this is my HelloWorldPanel.java :

public class HelloWorldPanel extends Composite
{
  interface HelloWorldUiBinder extends UiBinder<Widget , HelloWorldPanel> {}

  private static HelloWorldUiBinder uiBinder = GWT.create(HelloWorldUiBinder.class);

  @UiField TextBox nameTextBox;

  @UiField Button goButton;

  public HelloWorldPanel()
  {
    initWidget(uiBinder.createAndBindUi(this));

    nameTextBox = new TextBox();
    nameTextBox.setText("World");

    goButton = new Button("Go");
    goButton.addClickHandler(new ClickHandler()
    {
      @Override
      public void onClick(ClickEvent event)
      {
        System.out.println("clicked , event = " + event);
        Window.alert("Hello " + nameTextBox.getValue());
      }
    });
  }
}

And HelloWorldPanel.ui.xml :

<ui:UiBinder 
  xmlns:ui="urn:ui:com.google.gwt.uibinder"
  xmlns:g="urn:import:com.google.gwt.user.client.ui">

  <g:HTMLPanel>
    <g:TextBox ui:field="nameTextBox" />
    <g:Button  ui:field="goButton" text="Go"/>
  </g:HTMLPanel>

</ui:UiBinder>

It’s a very basic “Composite” widget , but the TextBox and Button in HelloWorldPanel just not working. The default value (“World”) is not shown , and button has no reaction , no System.out message …

But the Button defined in onModuleLoad() just works well , I don’t know why…. Can somebody tell me where goes wrong ? Thanks a lot !

Another question :
What’s the difference between RootPanel.get().add(helloWorldPanel); and RootPanel.getBodyElement().appendChild(helloWorldPanel.getElement()); ? It seems the same result …

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T20:54:21+00:00Added an answer on May 15, 2026 at 8:54 pm

    You don’t have to (or to be more precise: you mustn’t) instantiate the Widgets annotated with @UiField – UiBinder does that for you. So, in your code, you discard those Widgets and create your own – but since they are not added to the DOM, they don’t receive DOM events. Remove the nameTextBox = new TextBox(); and goButton = new Button("Go"); lines and you should be fine 🙂

    PS: If you need to create a Widget with some custom parameters, see the good docs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry if this is an elementary question but I've just started to consider whether
Sorry for this not being a real question, but Sometime back i remember seeing
Sorry if this sounds like a really stupid question, but I need to make
Sorry for a long question but here goes. I am trying to modify the
Sorry if this is a newbie question. I have searched but found nothing... Using
Sorry about this long block of code, but I think it makes sense to
Sorry for what seems like a silly question: But I've never, ever worked with
Sorry if this seems like a silly question - I am an amateur when
Sorry for the vague topic but I'm having a hard time explaining this. What
Sorry for this newbie question but I cannot figure how I can do this..

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.