I've a little problem right there. When I want to populate DataTable in JSF I have to create a model first, then use it in my view. Like on Primefaces sample here.
And now, I have to create DataTable that will display data, that came from webservice. I don't know how many columns there will be, and I don't know their names... Could you recommend some wise solution ?
PS. I don't know also how to returned data from webservice - it is still to determine.
EDIT
public Bean() {
columns = new ArrayList<String>();
rows = new ArrayList<Map<String, Object>>();
populateColumns(columns,4);
for(int i = 0 ; i < 6 ; i++)
{
Map<String,Object> m = new HashMap<String,Object>();
m.clear();
for(int j = 0 ; j < 4 ; j++)
{
m.put("Column" + j, "sth" + j + i);
}
rows.add(m);
}
}
private void populateColumns(List<String> list, int size) {
for(int i = 0 ; i < size ; i++)
list.add("Column" + i);
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…