Panel | ||||
---|---|---|---|---|
| ||||
|
Wicket Extensions: DataTable links
Question
I'm using a DataTable
(DefaultDataTable
) and a DataProvider
(SortableDataProvider
).
My table has one column like PropertyColumn(new Model("name'), name, name)
.
Is it possible to have a linkable name instead of a plain name?'''
Answer
The answer is yes
Instead of using a PropertyColumn you have to implement your own column that creates a panel/fragment with the link and text. (Thanks Igor)
Details
There are broadly two variations, the override and the standalone class, but both use the same HTML,
i.e.
Code Block |
---|
<wicket:panel> <a href="#" wicket:id="link"><span wicket:id="label">link</span></a> </wicket:panel> |
Overriding
Code Block |
---|
{panel} columns[0] = new TextFilteredPropertyColumn(new Model("Id"), "id", "id") { // add the LinkPanel to the cell item public void populateItem(Item cellItem, String componentId, IModel model) { final Transaction transaction = (Transaction) model.getObject(cellItem); cellItem.add(new TransactionList.LinkPanel(componentId, transaction)); } }; {panel} ... {panel} private class LinkPanel extends Panel { public LinkPanel(String id, Transaction transaction) { super(id); final String name = transaction.getId(); PageParameters param = new PageParameters("id=" + name); BookmarkablePageLink link = new BookmarkablePageLink("link", TransactionDetail.class, param); link.add(new Label("label", name)); add(link); } {panel} |
A Standalone Component
Posted to the mailing list by Joe Toth (Thanks, Joe)
...