This is a sub question I ask before, but I reformulate it to be more specific!
I want to get the records sent by a datasource with client side code.
The datasource work and return 1 row.
I tried to interact with the datasource directly, but I got an
index out of bound on userDS.getCacheData (it is empty):
DataSource userDS = DataSource.get("user");
userDS.setCacheAllData(true);
userDS.fetchData();
Record r = userDS.getCacheData()[0];
User user = new User();
user.setName(r.getAttributeAsString("Name"));
user.setRead(r.getAttributeAsBoolean("Read"));
user.setWrite(r.getAttributeAsBoolean("Write"));
user.setAdmin(r.getAttributeAsBoolean("Admin"));
So I tried to get it through a ListGrid, but got only null value.
DataSource userDS = DataSource.get("user");
ListGrid grid = new ListGrid();
grid.setDataSource(userDS);
grid.fetchData();
ListGridRecord r = grid.getRecord(0);
User user = new User();
user.setName(r.getAttributeAsString("Name"));
user.setRead(r.getAttributeAsBoolean("Read"));
user.setWrite(r.getAttributeAsBoolean("Write"));
user.setAdmin(r.getAttributeAsBoolean("Admin"));
What is the correct way to do this?
Thank in advance for your help!
I want to get the records sent by a datasource with client side code.
The datasource work and return 1 row.
I tried to interact with the datasource directly, but I got an
index out of bound on userDS.getCacheData (it is empty):
DataSource userDS = DataSource.get("user");
userDS.setCacheAllData(true);
userDS.fetchData();
Record r = userDS.getCacheData()[0];
User user = new User();
user.setName(r.getAttributeAsString("Name"));
user.setRead(r.getAttributeAsBoolean("Read"));
user.setWrite(r.getAttributeAsBoolean("Write"));
user.setAdmin(r.getAttributeAsBoolean("Admin"));
So I tried to get it through a ListGrid, but got only null value.
DataSource userDS = DataSource.get("user");
ListGrid grid = new ListGrid();
grid.setDataSource(userDS);
grid.fetchData();
ListGridRecord r = grid.getRecord(0);
User user = new User();
user.setName(r.getAttributeAsString("Name"));
user.setRead(r.getAttributeAsBoolean("Read"));
user.setWrite(r.getAttributeAsBoolean("Write"));
user.setAdmin(r.getAttributeAsBoolean("Admin"));
What is the correct way to do this?
Thank in advance for your help!
Comment