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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:17:58+00:00 2026-06-04T17:17:58+00:00

I am using GWT and AppEngine for a project. I would like to know

  • 0

I am using GWT and AppEngine for a project. I would like to know how can I share data (ArrayList objects)between widgets, so I could centralize the logic and reduce the number of RPC calls to the server.

I have thought of two ways, but I don’t know which is better:

1) When I instantiate the widget, I pass the ArrayList object as a parameter, although I don’t know how to do that because the widget gets instantiated with :

  ThisAppShell shell = GWT.create(ThisAppShell.class);    

2) By using a mechanism like eventBus

http://www.dev-articles.com/article/Gwt-EventBus-(HandlerManager)-the-easy-way-396001

When the user loads the application,after the login process is complete, I would like to download a list of employees which should be available for all widgets. This should all be done in the onModuleLoad() method. I would like to download them all at startup because I would like to implement some sort of caching mechanism. For example, I want to have 2 ArrayList instances:
– emplListOnStart which is populated when the application is loading
– emplListChanges, an array on which the user will make modifications from inside widgets.

After the user has finished making the changes (he presses the “Save” button), the two arrays will be compared, the differences will be saved in appengine (via RPC) and also updated in emplListOnStart.

This is the code for the EntryPoint class:

public class ThisApp implements EntryPoint {
ThisAppShell shell = GWT.create(ThisAppShell.class);
LoginServiceAsync loginService = GWT.create(LoginService.class);

private ArrayList<Employee> emplListOnStart;

private ArrayList<Employee> emplListChanges;

public void onModuleLoad() {
    RootLayoutPanel.get().clear();
    RootLayoutPanel.get().add(shell);
    loginService.isAuthenticated(new AsyncCallback<UserDto>() {

        public void onFailure(Throwable caught) {
            // TODO Auto-generated method stub

        }

        public void onSuccess(UserDto result) {
                             //Here I should load the emplListOnStart list;
        }

    });
    shell.getLogoutLink().addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            loginService.logout(new AsyncCallback() {
                public void onFailure(Throwable caught) {

                }

                public void onSuccess(Object result) {
                                             //Here the user will get logged out
                }
            });
            Window.Location.assign("");
        }
    });

   }
}

And here is the code for the widget:

public class ThisAppShell extends Composite {

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

interface ThisAppShellUiBinder extends UiBinder<Widget, ThisAppShell> {
}

@UiField
Anchor logout_link;
@UiField
StackLayoutPanel stackLPanel;
@UiField
TabLayoutPanel tabLPanel;

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

    initializeWidget();
}

public void initializeWidget() {
    stackLPanel.add(new HTML("Manage empl."), new HTML("Employees"), 30);
    stackLPanel.add(new HTML("Manage Dept."), new HTML("Departments"), 30);

    // Add a home tab
    HTML homeText = new HTML("This is the home tab");
    tabLPanel.add(homeText, "Home");

    // Add a tab
    HTML moreInfo = new HTML("This is the more info tab");
    tabLPanel.add(moreInfo, "More info");

    // Return the content
    tabLPanel.selectTab(0);
}

public Anchor getLogoutLink() {
    return logout_link;
}

}

Is this possible, or how could this be done better?

Thank you.

  • 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-04T17:17:59+00:00Added an answer on June 4, 2026 at 5:17 pm

    I think there are two ways to do it:

    1. Create a setter on your widget to set your ArrayList instances (setData()). You can then call this function in the onSuccess method of your loginService.

    2. Inject the singleton instance of a global EventBus into your widget (using i.e. gin/guice) and fire an event containing your data. In the widget you have to attach an EventHandler for the specific event (i.e. LoadEmplListEvent).

    I think both solutions are fine to use.
    Solution one creates a tighter coupling to your widget but is easier to implement and I think you should take this route if you only have a small number of widgets where you work
    with the data.

    Solution is a cleaner approach because it de-couples your widgets from the rest. You fire the event the data in your onSuccess method once and you don’t care about the widgets.
    The widgets that are interested in the data will make sure that they handle the event appropriately (by handling the event). I guess if you have a lot of widgets that have to deal with the data the second approach is the one to go for.

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

Sidebar

Related Questions

I am using GWT (and GWT-Plateform) and GAE, and I would like to have
I am using the GWT Eclipse plugin to develop and test a GWT appengine
I'm creating a GWT app in Google App Engine, and using Google data store.
Hi i am using GWT after i came to know that GWT will convert
I have an application built with GWT/Appengine/Jdo...and i am using Google User Service for
I'm writing a small application using GWT and JDOs to store persistent data. I've
I've created a GWT project using Eclipse which was working perfectly (I was able
Using GWT with the MVP pattern , I'd like to have a place that
I am using GWT 2.0.3 with ext in my application.This project is no longer
I'm using GWT 2.2.0 and GXT 2.2.3. In my project, I have a grid

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.