listgrid appears but not the data

hi all,

i am new to gwt. i recently followed the mysqlconn example Google Code Archive - Long-term storage for Google Code Project Hosting. and combine with the smartgwt’s listgrid and hlayout.

my listgrid appears but my data don’t. can someone advice me?

below is my bibleinfowidget code:

 package com.tribling.gwt.test.mysqlconn.client;


import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.SourcesTableEvents;
import com.google.gwt.user.client.ui.TableListener;
import com.google.gwt.user.client.ui.VerticalPanel;


import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.DragDataAction;
import com.smartgwt.client.types.ListGridFieldType;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.layout.HLayout;



public class BibleInfoWidget extends Composite implements TableListener {

 // rpc init Var 
 private MySQLConnServiceAsync callProvider;
 // main widget panel
 
 private VerticalPanel pWidget = new VerticalPanel();
 private LoadingWidget loading = new LoadingWidget();
 private VerticalPanel pBibleTable = new VerticalPanel();
 
  HLayout hLayout = null;
  ListGrid displayGrid = null;

  
 /**
  * constructor - init the composite widget for use 
  */
 public BibleInfoWidget() {
  
  HorizontalPanel hp = new HorizontalPanel();
  
  hp.add(loading);
  
  pWidget.add(hp);
  pWidget.add(pBibleTable);
  
  // init widget, this can be added into the rootpanel
  initWidget(pWidget);
  
  // init the rpc
  rpcInit();
  
  // start the process
  getBibleInfo();
 }
 
 /**
  * draw bible info to screen after rpc callback
  * 
  * @param bibleData
  */
 private void drawBibleInfo() {
  
  hLayout = new HLayout();
  //hLayout.setMembersMargin(50);
  //hLayout.setLayoutMargin(50);
  
  displayGrid = new ListGrid();  
  displayGrid.setWidth(380);  
  displayGrid.setHeight(500);
  displayGrid.setAlternateRecordStyles(true);  
  displayGrid.setShowAllRecords(true);  
  displayGrid.setCanReorderRecords(true);  
  displayGrid.setCanDragRecordsOut(true);  
  displayGrid.setCanAcceptDroppedRecords(true);  
  displayGrid.setDragDataAction(DragDataAction.MOVE); 
  
  
  ListGridField dayField = new ListGridField("dayField", "day", 120);  
  dayField.setAlign(Alignment.CENTER);  
  ListGridField dateField = new ListGridField("dateField", "date", 120);  
  dateField.setAlign(Alignment.CENTER); 
  ListGridField trialField = new ListGridField("trialField", "trial", 120);  
  trialField.setAlign(Alignment.CENTER); 
  
   
   displayGrid.setFields(new ListGridField[]{dayField, dateField, trialField});  
   

   
   displayGrid.setData(getRecords());  

   
   hLayout.addMember(displayGrid);  
   hLayout.draw(); 
  
 }
 
 private DisplayRecord[] getRecords() {
 
   return new DisplayRecord[]{
      new DisplayRecord("dsfasda","asdfsaf","asdfas"),
      new DisplayRecord("dsfasda","asdfsaf","asdfas"),
      new DisplayRecord("sdfsafa","asdfas","asdfas"),
      new DisplayRecord("asdfsdfa","sdafsafas","asdfasd"),
      new DisplayRecord("asdfsasd","asdfasdas","afsdaa"),
      new DisplayRecord("asdfasdfas","asdfasasdf","sdfasdfdasds"),
     
   };
  /*int rows = displayData.length;
  
  DisplayRecord[] result = new DisplayRecord[rows];
  
  for (int i = 0; i < rows; i++) { 

      System.out.println("displayData[i].id = " + displayData[i].id);
      System.out.println("displayData[i].type = " + displayData[i].type);
      System.out.println("displayData[i].email = " + displayData[i].email);
     
     result[i] = new DisplayRecord(displayData[i].id, displayData[i].type, displayData[i].email);
  }
  
  System.out.println("RESULT SIZE = " + result.length);
  System.out.println("ROWS SIZE = " + rows);
  
  return result;*/
}
 

 

 /**
  * Init the RPC provider
  * 
  * NOTE: ./public/MySQLConn.gwt.xml - determines the servlet context
  * read more of my gwtTomcat documentation in http://gwt-examples.googlecode.com
  */
    private void rpcInit() {
     callProvider = (MySQLConnServiceAsync) GWT.create(MySQLConnService.class);
        ServiceDefTarget target = (ServiceDefTarget) callProvider;
        
        // The path 'MySQLConnService' is determined in ./public/MySQLConn.gwt.xml
        // This path directs Tomcat to listen for this context on the server side, 
        // thus intercepting the rpc requests.
        String moduleRelativeURL = GWT.getModuleBaseURL() + "MySQLConnService";
        target.setServiceEntryPoint(moduleRelativeURL);
    }
 
 
 /**
  * rpc request to get the bible info. 
  * 
  * on return, draw the data to screen
  */
 private void getBibleInfo() {

  // draw loading
  loading.show();
  
  AsyncCallback callback = new AsyncCallback() {
   
   // fail
   public void onFailure(Throwable ex) {
    RootPanel.get().add(new HTML(ex.toString()));
   }

   // success
   public void onSuccess(Object result) {
    
    // Cast the result into the object that was sent
    // This casts the random object into BibleData
    // Since the object is an array we use [] 
    BibleData[] displayData = (BibleData[]) result; 
    
    // draw bible info
    drawBibleInfo();
    
    
    // hide loading
    loading.hide();

   }
  };
    
  // remote procedure call to the server to get the bible info
  callProvider.getBibleInfo(callback);
 }


 /**
  * observe
  */
 public void onCellClicked(SourcesTableEvents sender, int row, int cell) {
  
  // you can listen to clicks on the table with this.
  
 }
}


class DisplayRecord extends ListGridRecord {

    public DisplayRecord() {
    }
    
    public DisplayRecord(String day, String month, String trials) {
        setYear(day);
        setMonth(month);
        setDay(trials);
    }

    public DisplayRecord(String year, String month, String day, String trials) {

        setYear(year);
        setMonth(month);
        setDay(day);
     
    }

    public void setYear(String day) {
        setAttribute("day", day);
    }

    public String getYear() {
        return getAttributeAsString("day");
    }

    public void setMonth(String month) {
        setAttribute("month", month);
    }

    public String getMonth() {
        return getAttributeAsString("month");
    }

    public void setDay(String trials) {
        setAttribute("trials", trials);
    }

    public String getDay() {
        return getAttributeAsString("trials");
    }

    /*public void setTrials(String trials) {
        setAttribute("trials", trials);
    }

    public int getTrials() {
        return getAttributeAsInt("trials");
    }*/
}

can someone help me? i am using gwt-window-1.5.3.

below is the listgrid code extracted from bibleinfowidget above.

hLayout = new HLayout();
  //hLayout.setMembersMargin(50);
  //hLayout.setLayoutMargin(50);
  
  displayGrid = new ListGrid();  
  displayGrid.setWidth(380);  
  displayGrid.setHeight(500);
  displayGrid.setAlternateRecordStyles(true);  
  displayGrid.setShowAllRecords(true);  
  displayGrid.setCanReorderRecords(true);  
  displayGrid.setCanDragRecordsOut(true);  
  displayGrid.setCanAcceptDroppedRecords(true);  
  displayGrid.setDragDataAction(DragDataAction.MOVE); 
  
  
  ListGridField dayField = new ListGridField("dayField", "day", 120);  
  dayField.setAlign(Alignment.CENTER);  
  ListGridField dateField = new ListGridField("dateField", "date", 120);  
  dateField.setAlign(Alignment.CENTER); 
  ListGridField trialField = new ListGridField("trialField", "trial", 120);  
  trialField.setAlign(Alignment.CENTER); 
  
   
   displayGrid.setFields(new ListGridField[]{dayField, dateField, trialField});  
   

   
   displayGrid.setData(getRecords());  

   
   hLayout.addMember(displayGrid);  
   hLayout.draw();

Did you try
displayGrid.fetchData();
after the line
displayGrid.setData(getRecords());
?

thank you mihai007 for replying.

But it doesn’t make it work.

the listgrid is working fine and the number of rows and columns are correct according to the number of ListGridRecord. But the data inside the listgrid just don show up.

can someone advise me? do i need to post more code? thank you

can someone please advice me ?

can it be due to the css? or any configuration that is done wrongly?

as i think the code should have no problem. thanks

Most likely your declared field names do not match the data. Field names are case sensitive.

Is there any way to make the field names case insensitive?

No, and this wouldn’t really make sense, as it would make accessing values convenient and slower in some circumstances.

This doesn’t seem like it should be a difficult problem for you - what’s the issue?

Some of the field names in the REST database response changed to all upper case.
I can change the fields in my RestDataSource to matched the new names. Just thought it would be easier if there is a switch that can turn case sensitivity on and off, even if it might slow things down a lit..

Thanks!