Table of contents

Wicket Extensions: DataTable links


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?'''


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)


There are broadly two variations, the override and the standalone class, but both use the same HTML,

<a href="#" wicket:id="link"><span wicket:id="label">link</span></a>


        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));


    private class LinkPanel extends Panel {
        public LinkPanel(String id, Transaction transaction) {
            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));

A Standalone Component

Posted to the mailing list by Joe Toth (Thanks, Joe)
Don't forget to create a LinkPropertyColumn$LinkPanel.html file with the html from above.

abstract public class LinkPropertyColumn<T> extends PropertyColumn<T> {

	PopupSettings popupSettings;
	IModel labelModel;

	public LinkPropertyColumn(IModel displayModel, String sortProperty,
			String propertyExpression, PopupSettings popupSettings) {
		this(displayModel, sortProperty, propertyExpression);
		this.popupSettings = popupSettings;

	public LinkPropertyColumn(IModel displayModel, IModel labelModel) {
		super(displayModel, null);
		this.labelModel = labelModel;

	public LinkPropertyColumn(IModel displayModel, String sortProperty,
			String propertyExpression) {
		super(displayModel, sortProperty, propertyExpression);

	public LinkPropertyColumn(IModel displayModel, String propertyExpressions) {
		super(displayModel, propertyExpressions);

	public void populateItem(Item item, String componentId, IModel model) {
		item.add(new LinkPanel(item, componentId, model));

	* Override this method to react to link clicks.
	* Your own/internal row id will most likely be inside the model.
	public abstract void onClick(Item item, String componentId, IModel model);

	public class LinkPanel extends Panel {

		public LinkPanel(final Item item, final String componentId,
				final IModel model) {

			Link link = new Link("link") {

				public void onClick() {
					LinkPropertyColumn.this.onClick(item, componentId, model);


			IModel tmpLabelModel = labelModel;

			if (labelModel == null) {
				tmpLabelModel = createLabelModel(model);

			link.add(new Label("label", tmpLabelModel));
  • No labels