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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:36:18+00:00 2026-05-31T13:36:18+00:00

I am trying to make a sample code for my further work. I am

  • 0

I am trying to make a sample code for my further work. I am using gwt vanillia and new to gwt. My purpose is to populate some textboxes and a grid. for populating textboxes from database, no problem with rpc call. But I could’nt populate datagrid via using RPC call. I used Bastian Tenbergen’s tutorial
for populating some textboxes. But when i tried to populate the grid with asyncronious callback using ArrayList, code failed. I know ArrayList is also serializable but I can’t solve the issue.
Any advice is appreciated.
Here is some code for my questin.
In server package: SqlDbConnection.java

    public ArrayList<hastaGrid> callGrid(String something){
    ArrayList<hastaGrid> list = new ArrayList<hastaGrid>();
    hastagrid hastaGrid = null;     
    try {
        Statement st = conn.createStatement();
        ResultSet result = st.executeQuery("select name from TEST where name = '"+ something +"'");

        while(result.next()) {
            hastagrid = new hastaGrid(result.getString(1), result.getString(2),result.getNString(2),result.getString(3));
            list.add(hastaGrid);
            System.out.println("result: " +hastagrid.getLogin().toString()+" " + hastagrid.getPassword() +" "+ hastagrid.getName() +" " + hastagrid.getSurname());
        }
        result.close();
        st.close();                 
    } catch (Exception e) {
        e.printStackTrace();
    }       
    return list;
}

In client package: hastaGrid.java //the class also have getter and setter methods.

public class hastaGrid implements IsSerializable {

private String name;
private String surname;
private String login;
private String password;

public hastaGrid(String name,String surname, String login, String password){
    this.setName(name);
    this.setSurname(surname);
    this.setLogin(login);
    this.setPassword(password);
}}

In client package: DBConnection.java

public interface DBConnection extends RemoteService {   
public ArrayList<hastaGrid> callGrid(String name);  }

In client package: DBConnectionAsync.java

public interface DBConnectionAsync {    
public void callGrid(String name, AsyncCallback<ArrayList<hastaGrid>> callback);   }

In client package: userDetail.java

onModuleLoad() {
AsyncCallback> callback = new AuthenticationHandler1();
rpc.gridGetir(“John”,callback);
}

private class AuthenticationHandler<T> implements AsyncCallback<ArrayList<hastaGrid>>  {
    public void onFailure(Throwable ex) {
    RootPanel.get().add(new HTML("RPC call failed"));
    }
    public void onSuccess(ArrayList<hastaGrid> result) {        
    result.get(0).getName(); } } // I just want to reach some result here when debugging.

I read lots of pages on web but can’t find a specific solution. I could be wrong. Thanks for responses.

  • 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-31T13:36:19+00:00Added an answer on May 31, 2026 at 1:36 pm

    First you should make sure that your RPC returns the appropriate List of hastaGrid objects – and please do capitalize the class name 🙂
    I use the AsyncDataProvider model quite a lot with various DataGrid implementations and create an implementing class somewhat like the following:

    public class MyProvider extends AsyncDataProvider<MyModelObject> implements AsyncCallback<List<MyModelObject>> {
        static int PAGESIZE = 50;
        List<MyModelObject> cache = new ArrayList<MyModelObject>();
    
        @Override
        protected void onRangeChanged(HasData<MyModelObject> display) {
            final Range range = display.getVisibleRange();          
            int start = range.getStart();
            int end = start + range.getLength();
            if (start >= cache.size() - 1) {
                lastVisible = cache.size() - 1;
                gwtService.fetchRowsFromDbase(this);                
                return;
            }
            List<MyModelObject> dataInRange = cache.isEmpty() ? new ArrayList<MyModelObject>() : cache.subList(start,
                    end >= cache.size() ? (cache.size()) : end);
            updateRowData(start, dataInRange);
        }
    
        public void onFailure(Throwable caught) {
            Window.alert(caught.getMessage());
        }
    
        public void onSuccess(List<MyModelObject> result) {
            if (result.isEmpty()) {
                //display a warning
                return;
            }
            for (MyModelObject a : result) {
                if (cache.indexOf(a) == -1)
                    cache.add(a);
            }
            updateRowData(cache.indexOf(result.get(0)), result);
            updateRowCount(cache.size(), result.size() < PAGESIZE);
            tab.setPageSize(PAGESIZE);
            tab.setPageStart(lastVisible);
            MyModelObject last = cache.get(cache.size() - 1);
            orderOffset = last.getId();         
        }
    
        public List<MyModelObject> getCache() {
            return cache;
        }
    }
    

    In your DataGrid initalization code you put:

    MyProvider pr = new MyProvider();
    pr.addDataDisplay(yourDataGrid);
    

    This approach works best if you also add a pager, because the dataprovider listens to range changes, triggered by clicking the pager.

    SimplePager pager = new SimplePager();
    pager.setDisplay(yourDataGrid);
    //don't forget to add the pager widget to the DOM 
    

    Hope this helps!

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

Sidebar

Related Questions

I'm new to MVC. Trying out some sample code to list items from db.
I'm trying to make some html with css pages (I'm new to both) and
Here's my 'sample code', including what I'm trying to do. Obviously, it doesn't work
More specifically I'm trying to make the google adwords API work using PHP 4.
Below is a some sample code I am trying to update. The client would
I am trying to make a simple alarm. in this code portion a take
i'm currently trying to make a asp.net mvc3 app. in the sample application which
I'm trying to make simple script using jquery $post function to pass data to
I'm trying to make a basic client-server application for windows phone 7 (using Mango
I am creating a Linux terminal program using C. I am trying to make

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.