java.lang.Object
org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn<T,S>
org.apache.wicket.extensions.markup.html.repeater.data.table.LambdaColumn<T,S>
Type Parameters:
T - The Model object type
S - the type of the sort property
All Implemented Interfaces:
Serializable, ICellPopulator<T>, IExportableColumn<T,S>, IColumn<T,S>, IStyledColumn<T,S>, IDetachable, IClusterable

public class LambdaColumn<T,S> extends AbstractColumn<T,S> implements IExportableColumn<T,S>
An implementation of column that adds a label to the cell whose model is determined by the provided SerializableFunction that is evaluated against the current row's model object

Example for a table of Contacts:

 columns[0] = new LambdaColumn(new Model<String>("First Name"), Contact::getFirstName);
 
The above will attach a label to the cell which calls #getFirstName() for each displayed contact.
See Also:
  • Constructor Details

    • LambdaColumn

      public LambdaColumn(IModel<String> displayModel, org.danekja.java.util.function.serializable.SerializableFunction<T,?> function)
      Creates a column that is not sortable.
      Parameters:
      displayModel - display model
      function - Wicket function to be applied to each row
    • LambdaColumn

      public LambdaColumn(IModel<String> displayModel, S sortProperty, org.danekja.java.util.function.serializable.SerializableFunction<T,?> function)
      Creates a property column that is also sortable.
      Parameters:
      displayModel - display model
      sortProperty - sort property
      function - Wicket function to be applied to each row
  • Method Details

    • populateItem

      public void populateItem(Item<ICellPopulator<T>> item, String componentId, IModel<T> rowModel)
      Description copied from interface: ICellPopulator
      Method used to populate a cell in the DataGridView Implementation MUST add a component to the cellItem using the component id provided by componentId argument, otherwise a WicketRuntimeException will be thrown
      Specified by:
      populateItem in interface ICellPopulator<T>
      Parameters:
      item - the item representing the current table cell being rendered
      componentId - the id of the component used to render the cell (only one component should be added to the cell)
      rowModel - the model of the row item being rendered. this model usually contains the model provided by the data provider.
      See Also:
    • getDataModel

      public IModel<?> getDataModel(IModel<T> rowModel)
      Factory method for generating a model that will generated the displayed value.
      Specified by:
      getDataModel in interface IExportableColumn<T,S>
      Parameters:
      rowModel -
      Returns:
      model