Skip to content

Instantly share code, notes, and snippets.

@topriddy
Created January 23, 2012 10:28
Show Gist options
  • Save topriddy/1662373 to your computer and use it in GitHub Desktop.
Save topriddy/1662373 to your computer and use it in GitHub Desktop.
private void addCompanyTable() {
IDataProvider dataProvider = new IDataProvider() {
public Iterator iterator(int first, int count) {
Iterator iter = null;
try {
List<TrackDeviceCompany> list = dao.findAll(TrackDeviceCompany.class, first, count);
iter = list.iterator();
} catch (Exception ex) {
logger.error("Exception occured getting iterator for company", ex);
}
return iter;
}
public int size() {
int size = 0;
try {
size = dao.countAll(TrackDeviceCompany.class);
} catch (MTrackerException ex) {
logger.error("Error getting count size of company", ex);
}
return size;
}
public IModel model(Object object) {
return new IModel<TrackDeviceCompany>() {
TrackDeviceCompany company;
public TrackDeviceCompany getObject() {
return company;
}
public void setObject(TrackDeviceCompany object) {
company = object;
}
public void detach() {
//not implemented
}
};
}
public void detach() {
}
};
DataView companyDataView = new DataView<TrackDeviceCompany>("companyTable", dataProvider, ROWS) {
@Override
protected void populateItem(Item<TrackDeviceCompany> item) {
TrackDeviceCompany company = item.getModelObject();
item.add(new Label("snos", new Model(item.getIndex() + 1)));
item.add(new Label("companyName", new Model((company == null ? "null" : company.getName()))));
item.add(new Label("numberOfModels", new Model("X")));
item.add(new Label("numberOfTrackDevices", new Model("Y")));
item.add(new Link("view") {
@Override
public void onClick() {
//doo nothing
}
});
item.add(new Link("delete") {
@Override
public void onClick() {
//doo nothing
}
});
}
};
add(companyDataView);
add(new PagingNavigator("companyPageNavigator", companyDataView));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment