Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

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.

Code Block
abstract public class LinkPropertyColumnLinkPropertyColumn<T> extends PropertyColumnPropertyColumn<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);
	}

	@Override
	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) {
			super(componentId);

			Link link = new Link("link") {

				@Override
				public void onClick() {
					LinkPropertyColumn.this.onClick(item, componentId, model);
				}
			};
			link.setPopupSettings(popupSettings);

			add(link);

			IModel tmpLabelModel = labelModel;


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

			link.add(new Label("label", tmpLabelModel));
		}
	}
}