I am new to Wicket and am trying to add purely dynamic content in wicket. I have a list of object TableDataValuesVO which has a String tableName and a map columnNamesAndValues (containing columnName And its value). Each object in the list represent different data records of different table (the size of columnNameAndValues differ for each object). As of now I am using repeatingview for columnName and Value.but it displays one columnName per row and below that one columnValue per row.
Class to generate this component:
Html:
<table wicket:id="applicationDataView">
Java:
boolean columnNameRendered = false;
applicationDataView = new RepeatingView("applicationDataView")
RepeatingView tableView = new RepeatingView(applicationDataView.newChildId());
RepeatingView columnNameView = new RepeatingView(applicationDataView.newChildId());
tableView.add(new Label(applicationDataView.newChildId(),tableName));
applicationDataView.add(columnNameView);
applicationDataView.add(tableView);
List<dataVO> dataForTable= applicationDataByTable.get(tableName);
for (DataVO dataVO: dataForTable)
{
RepeatingView columnValueView= new RepeatingView(applicationDataView.newChildId());
if (!columnNameRendered)
{
for (String columnName : dataVO.getColumnNamesAndValues().keySet())
{
columnNameView.add(new Label(tableName+columnName,columnName));
}
columnNameRendered = true;
}
for (String columnName : dataVO.getColumnNamesAndValues().keySet())
{
String columnValue = tableDataValuesForRecordVO.getColumnNamesAndValues().get(columnName);
columnValueView.add(new Label(applicationDataView.newChildId(),columnValue));
applicationDataView.add(columnValueView);
}
}
Actual result:
Table name1:
Column 1
Column 2
Column 3
Val11
Val12
....
Table name2:
Column 1
Column 2
Column 3
Column 4
Val11
Val12....
Expected Result:
Table Name1:
Col1 col2 Col3
val11 val12 val13
val21 val22 val23
Table Name2:
Co131 col32 Col33 col34
val11 val12 val13 val14
val21 val22 val23 val24
Please help in providing a solution to display the dynamic data?
You can use, for example, a
ListView
that draws a lot ofDataTable
s. (side note:I think this will be not very fast, as you will generate loads of HTML. )Java:
HTML: