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 8436973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:18:58+00:00 2026-06-10T07:18:58+00:00

Bellow is some Java code from Google’s UIBinder tutorial . Together with a separate

  • 0

Bellow is some Java code from Google’s UIBinder tutorial. Together with a separate HTML page this code displays the text “Hello, World”.

public class HelloWorld {
    interface MyUiBinder extends UiBinder<DivElement, HelloWorld> {}
    private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class);

    @UiField SpanElement nameSpan;

    public HelloWorld() {
        setElement(uiBinder.createAndBindUi(this));
    }

    public void setName(String name) { 
        nameSpan.setInnerText(name); 
    }

    /**
    * Method in question
    */
    public void Element getElement() { 
        return nameSpan; 
    }
}

The getElement() method has a void return type but returns an Element called nameSpan. How is this possible given that it has a void return type?

  • 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-06-10T07:18:58+00:00Added an answer on June 10, 2026 at 7:18 am

    The explanation is simply, that the example in the documentation is “a little bit” broken.

    The implementation of setElement() and getElement() would be unnecessary anyway, if the example simply extended UIObject like

    public class HelloWorld extends UIObject {
    
      private static HelloWorldUiBinder uiBinder = 
            GWT.create(HelloWorldUiBinder.class);
    
      interface HelloWorldUiBinder extends UiBinder<Element, HelloWorld> {
      }
    
      @UiField
      SpanElement nameSpan;
    
      public HelloWorld() {
        setElement(uiBinder.createAndBindUi(this));
      }
    
      public void setName(String name) { 
        nameSpan.setInnerText(name); 
      }
    
    }
    

    By the way, here’s a standalone variation of the UiBinder “hello world” example (which might be easier to understand as a first UiBinder example):

    public class HelloWorld implements EntryPoint {
    
      interface HelloWorldUiBinder extends UiBinder<Element, HelloWorld> {
      }
    
      @UiField SpanElement nameSpan;
    
      public void onModuleLoad() {
        final HelloWorldUiBinder uiBinder = GWT.create(HelloWorldUiBinder.class);
        final Element element = uiBinder.createAndBindUi(this);
        nameSpan.setInnerText("world");
        Document.get().getBody().appendChild(element);
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im trying to extract some files from a jar-file downloaded using java-webstart. below code
I use the bellow code to load the main menu elements from some CMS,
i have done some code in jquery but where i commented in this bellow
Below is some html I found in this jquery tooltip tutorial, the contents inside
I am trying to run some unix commands from my java code. I am
I'm porting some geolocation java code from http://janmatuschek.de/LatitudeLongitudeBoundingCoordinates#Java (shown below) to python. It can
I'm trying to prototype some pretty simple Hibernate code originating from a tutorial and
Im trying to develop a simple java code which will upload some contents from
Is there a tutorial on how to run Ant from Java? I got some
I want to execute some Unix commands from the java code. I want to

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.