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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:54:57+00:00 2026-05-17T01:54:57+00:00

Im moving first steps today on GWT framework. I need to understand (using the

  • 0

Im moving first steps today on GWT framework. I need to understand (using the netbeans official tutorial how this application work 🙂 I place the code :

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.yournamehere.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.rpc.AsyncCallback;

/**
 * Main entry point.
 *
 * @author djfonplaz
 */
public class MainEntryPoint implements EntryPoint {
    /** 
     * Creates a new instance of MainEntryPoint
     */
    public MainEntryPoint() {
    }

    public static GWTServiceAsync getService() {
        // Create the client proxy. Note that although you are creating the
        // service interface proper, you cast the result to the asynchronous
        // version of the interface. The cast is always safe because the
        // generated proxy implements the asynchronous interface automatically.

        return GWT.create(GWTService.class);
    }

    public void onModuleLoad() {
        final Label quoteText = new Label();

        Timer timer = new Timer() {
            public void run() {
                //create an async callback to handle the result:
                AsyncCallback callback = new AsyncCallback() {
                    public void onFailure(Throwable arg0) {
                        //display error text if we can't get the quote:
                        quoteText.setText("Failed to get a quote");
                    }

                    public void onSuccess(Object result) {
                        //display the retrieved quote in the label:
                        quoteText.setText((String) result);
                    }
                };
                getService().myMethod(callback);
            }
        };

        timer.scheduleRepeating(1000);
        RootPanel.get().add(quoteText);
    }
}

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.yournamehere.client;

import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;

/**
 *
 * @author djfonplaz
 */
@RemoteServiceRelativePath("gwtservice")
public interface GWTService extends RemoteService {
    public String myMethod();
}

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.yournamehere.client;

import com.google.gwt.user.client.rpc.AsyncCallback;

/**
 *
 * @author djfonplaz
 */
public interface GWTServiceAsync {
    public void myMethod(AsyncCallback callback);
}

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.yournamehere.server;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import org.yournamehere.client.GWTService;

/**
 *
 * @author djfonplaz
 */
public class GWTServiceImpl extends RemoteServiceServlet implements GWTService {
    private Random randomizer = new Random();
    private static final long serialVersionUID = -15020842597334403L;
    private static List quotes = new ArrayList();

    static {
        quotes.add("No great thing is created suddenly - Epictetus");
        quotes.add("Well done is better than well said - Ben Franklin");
        quotes.add("No wind favors he who has no destined port - Montaigne");
        quotes.add("Sometimes even to live is an act of courage - Seneca");
        quotes.add("Know thyself - Socrates");
    }

    public String myMethod() {
        return (String) quotes.get(randomizer.nextInt(5));
    }
}

So (more or less) :

  1. the standard welcomeGWT.html is served to the server, which call directly trought the JS created the servlet MainEntryProject.java
  2. MainEntryProject.java (when is loaded trought onModuleLoad()) which should generate the string and send to the client.

Right at this point?

What i don’t understand is :

  1. Who call the method myMethod() in GWTServiceImpl? Nobody ask this method, i just see getService().myMethod(callback), which should call the one of the GWTServiceAsync class.
  2. Who pass the string generated by GWTServiceImpls to public void onSuccess(Object result)?
  3. Why the getService() return GWTService and not the GWTServiceImpl? It should return a class, not an interface;

If someone can help me, would be really glad! cheers

  • 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-17T01:54:57+00:00Added an answer on May 17, 2026 at 1:54 am

    File MainEntryProject.java located in client package, so it’s not servlet – it’s java file which will be compiled by GWT to JavaScript. Resulted javascript embedded in your HTML file (welcomeGWT.html).
    So,

    • first loads welcomeGWT.html
    • then browser starts executing javascript generated by GWT, which after 1000ms calls server method myMethod
    • finally server return callback, client executing next code:

    public void onFailure(Throwable arg0) {
    quoteText.setText("Failed to get a quote");
    }
    public void onSuccess(Object result) {
    quoteText.setText((String) result);
    }

    Answers:
    1) Client calls that method.
    2) Client
    3) I could only guess, seems like it’s just how RPC roll

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

Sidebar

Related Questions

i'm moving my first steps into Django and i'm tryin' to follow the tutorial
Im moving first steps into JSF framework. I so make these jsp/bean : index.jsp
I am moving my first steps in the Entity Framework 4.0, and I am
I'm using Eclipse 3.4.1, moving my first steps. When I run my project (a
I'm moving my first steps in MonoMac. But I stopped right at the beginning
I'm moving my first steps in Scala and I would like to make the
I just made my first steps moving into Objective-C . I have a very
I'm moving my first stpes in iOS development. I have followed the first part
Moving rails app to production and running into the routing issues. I've read this
My Perl script is moving files onto an NFS mounted filesystem, using the move

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.