<table>
<tr wicket:id="rows">
<td wicket:id="cols"><span wicket:id="cell"></span></td>
</tr>
</table>
where the span points to the CustomizedPanel you want to display with different controls.
Java for the listviews:
public MyPage() {
add(new ListView("rows", rowList) {
protected void populateItem(ListItem item) {
// get columns from the item's model object:
List cols = ((Foo)item.getModelObject()).getFoo();
item.add(new ListView("cols", cols) {
protected void populateItem(ListItem item2) {
Object obj = item2.getModelObject();
if(obj instanceof Foo) {
item.add(new MyFooPanel("cell", obj);
} else if(obj instanceof Bar) {
item.add(new MyBarPanel("cell", obj);
} else {
item.add(new Label("cell", "unknown content"));
}
}
}
);
}
Braces etc may not match, but you get the idea :-)
The panel can contain anything you wish, just create different panels for each type of model object.
Martijn
On 12/18/05, Sriram Gopalan <[EMAIL PROTECTED]> wrote:
Hi,
I am new to Wicket and so far I love it. Thanks for the guys behind it.
In my application, there is a requirement to display tabular data, but the number of columns as well as the type of data in the columns are determined dynamically, that is, they are not known ahead of time when HTML is designed. How do I do this?
To explain further, there is a search functionality that searches across many objects (each with their own attributes). So, if the results are of type object1, there will be 'n' columns in the output (with each of them being one of the n attributes of object1) and if the results of of type object2, there will be 'm' columns in the output (with each column being one of the m attributes of object2).
Is it possible to do this using wicket? Generally speaking, is it always necessary to have the static HTML pages with hardcoded wicket:ids?
Thanks again.
- Sriram Gopalan
--
Living a wicket life...
Martijn Dashorst - http://www.jroller.com/page/dashorst
Wicket 1.1 is out: http://wicket.sourceforge.net/wicket-1.1
