Question

i am using simplepager class for adding pagination to the cell table,it was displaying the values for the first time while i was trying to view the next page results it shows nothing.... my code is:

SimplePager pager;
SimplePager.Resources pagerResources=GWT.create(SimplePager.Resources.class);
pager=new SimplePager(TextLocation.CENTER, pagerResources, true, 0,true);   

List<UserPage> userDetails=Arrays.asList(new UserPage("karthik",100.0,"SE"),
    new UserPage("suresh",200.0,"SE"),
    new UserPage("Srinivas",300.0,"SE"),
    new UserPage("Bhaskar",400.0,""),
    new UserPage("karthik",100.0,"SE"),
    new UserPage("suresh",200.0,"SE"),
    new UserPage("Srinivas",300.0,"SE"),
    new UserPage("Bhaskar",400.0,""),
    new UserPage("karthik",100.0,"SE"),
    new UserPage("suresh",200.0,"SE"),
    new UserPage("Srinivas",300.0,"SE"),
    new UserPage("Bhaskar",400.0,null));
ListHandler<UserPage> sortHandler=new ListHandler<UserPage>(userDetails);
HTML content=new HTML("Welcome Admin");
CellTable<UserPage> table=new CellTable<UserPage>();
pager.setDisplay(table);
pager.setPageSize(3);
EditTextCell nameCell=new EditTextCell();
Column<UserPage, String> nameColumn=new Column<UserPage, String>(nameCell) {
  @Override
  public String getValue(UserPage object) {
    // TODO Auto-generated method stub
    return object.getUserName();
  }
};
table.addColumn(nameColumn,"UserName");

EditTextCell userIdCell=new EditTextCell();
Column<UserPage, String> userIdColumn=new Column<UserPage, String>(userIdCell) {
  @Override
  public String getValue(UserPage object) {
    // TODO Auto-generated method stub
    return (object.getUserId()).toString();
  }
};
table.addColumn(userIdColumn, "UserID");

EditTextCell desgCell=new EditTextCell();
Column<UserPage, String> desgColumn=new Column<UserPage, String>(desgCell) {        
  @Override
  public String getValue(UserPage object) {
    // TODO Auto-generated method stub
    return object.getDesignation();
  }
};
table.addColumn(desgColumn,"Designtion");
//table.setPageSize(userDetails.size());
table.setRowCount(4,false);
table.setRowData(0,userDetails);        
table.addColumnSortHandler(sortHandler);
adminPage.add(content);
adminPage.add(table);
adminPage.add(pager);

let me know is there any wrong in my code..... thanks in advance....

Was it helpful?

Solution

i changed my code to:

ListDataProvider<UserPage> dataProvider=new ListDataProvider<UserPage>();  
dataProvider.addDataDisplay(table);
dataProvider.setDataDisplay(userDetails);

it was working now....

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top