org.ujorm.wicket.component.grid
Class KeyColumn<U extends Ujo,T>

java.lang.Object
  extended by org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn<U,KeyRing<U>>
      extended by org.ujorm.wicket.component.grid.KeyColumn<U,T>
All Implemented Interfaces:
Serializable, org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator<U>, org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn<U,KeyRing<U>>, org.apache.wicket.extensions.markup.html.repeater.data.table.IStyledColumn<U,KeyRing<U>>, org.apache.wicket.model.IDetachable, org.apache.wicket.util.io.IClusterable
Direct Known Subclasses:
KeyColumnBoolean, KeyColumnDate, KeyColumnEnum

public class KeyColumn<U extends Ujo,T>
extends org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn<U,KeyRing<U>>

A convenience implementation of column that adds a Ujo Property to the cell whose model is determined by the provided wicket key expression (same as used by PropertyModel) that is evaluated against the current row's model object

Example:

 public class DataTablePage2 extends WebPage {

     public DataTablePage2() {
         final EmployeeProvider userProvider = new EmployeeProvider();

         final List<IColumn> columns = new ArrayList<IColumn>();
         columns.add(new KeyColumn(Employee.ID));
         columns.add(new KeyColumn(Employee.FIRSTNAME));
         columns.add(new KeyColumn(Employee.LASTNAME));
         columns.add(new KeyColumn(Employee.EMAIL));
         columns.add(new KeyColumn(Employee.STUDENT));

         add(new DefaultDataTable("datatable", columns, userProvider, 20));
     }
 }
 
The above will attach a label to the cell with a key model for the expression "name.first"

Author:
Pavel Ponec
See Also:
KeyModel, Serialized Form

Field Summary
protected  String cssClass
          The CSS class of the column
protected  KeyRing<U> keySerializable
          Data key
static String PROPERTY_PREFIX
          Localization key prefix
static boolean SORTING_OFF
          Disable a grid column sorting
static boolean SORTING_ON
          Enable a grid column sorting
 
Constructor Summary
KeyColumn(org.apache.wicket.model.IModel<String> label, KeyRing<U> key, KeyRing<U> sortKey)
          Creates a sortable key column
KeyColumn(KeyRing<U> key, KeyRing<U> sortKey)
          Creates a sortable key column
 
Method Summary
protected  void appendCssClass(org.apache.wicket.Component value, U ujo)
          Append a CSS class - to overwriting only
protected  org.apache.wicket.Component createValueCoponent(String componentId, org.apache.wicket.model.IModel<?> valueModel, U ujo)
          Create the Label for a Value component, but no CSS class.
protected  org.apache.wicket.model.IModel<?> createValueModel(U ujo)
          Factory method for generating a model that will generated the displayed value.
 String getCssClass()
          
 Key<U,T> getKey()
          Get the Key
 String getPropertyExpression()
           
static
<U extends Ujo,T>
KeyColumn<U,T>
of(Key<U,T> key, boolean sorted)
          A factory method
static
<U extends Ujo,T>
KeyColumn<U,T>
of(Key<U,T> key, boolean sorted, String cssClass)
          A factory method
static
<U extends Ujo,T>
KeyColumn<U,T>
of(Key<U,T> key, Key<U,T> sort, String cssClass)
          A factory method
 void populateItem(org.apache.wicket.markup.repeater.Item<org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator<U>> item, String componentId, org.apache.wicket.model.IModel<U> rowModel)
          Implementation of populateItem which adds a label to the cell whose model is the provided key expression evaluated against rowModelObject
 void setCssClass(String cssClass)
          Assign a CSS class
 String toString()
          Domain class + key
 
Methods inherited from class org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn
detach, getDisplayModel, getHeader, getSortProperty, isSortable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SORTING_ON

public static final boolean SORTING_ON
Enable a grid column sorting

See Also:
Constant Field Values

SORTING_OFF

public static final boolean SORTING_OFF
Disable a grid column sorting

See Also:
Constant Field Values

PROPERTY_PREFIX

public static final String PROPERTY_PREFIX
Localization key prefix

See Also:
Constant Field Values

keySerializable

protected final KeyRing<U extends Ujo> keySerializable
Data key


cssClass

protected String cssClass
The CSS class of the column

Constructor Detail

KeyColumn

public KeyColumn(KeyRing<U> key,
                 KeyRing<U> sortKey)
Creates a sortable key column

Parameters:
key - Ujorm key to display in the column
sortKey - Optional persistent ujorm key to sorting
cssClass - optional argument for a CSS class

KeyColumn

public KeyColumn(org.apache.wicket.model.IModel<String> label,
                 KeyRing<U> key,
                 KeyRing<U> sortKey)
Creates a sortable key column

Parameters:
label - Column label
key - Ujorm key to display in the column
sortKey - Optional persistent ujorm key to sorting
cssClass - optional argument for a CSS class
Method Detail

populateItem

public void populateItem(org.apache.wicket.markup.repeater.Item<org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator<U>> item,
                         String componentId,
                         org.apache.wicket.model.IModel<U> rowModel)
Implementation of populateItem which adds a label to the cell whose model is the provided key expression evaluated against rowModelObject

See Also:
ICellPopulator.populateItem(Item, String, IModel)

getCssClass

public String getCssClass()

Specified by:
getCssClass in interface org.apache.wicket.extensions.markup.html.repeater.data.table.IStyledColumn<U extends Ujo,KeyRing<U extends Ujo>>
Overrides:
getCssClass in class org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn<U extends Ujo,KeyRing<U extends Ujo>>

setCssClass

public void setCssClass(String cssClass)
Assign a CSS class


createValueCoponent

protected org.apache.wicket.Component createValueCoponent(String componentId,
                                                          org.apache.wicket.model.IModel<?> valueModel,
                                                          U ujo)
Create the Label for a Value component, but no CSS class.

See Also:
appendCssClass(org.apache.wicket.Component, org.ujorm.Ujo)

createValueModel

protected org.apache.wicket.model.IModel<?> createValueModel(U ujo)
Factory method for generating a model that will generated the displayed value. Typically the model is a key model using the keySerializable specified in the constructor.

Parameters:
rowModel -
Returns:
model

getPropertyExpression

public String getPropertyExpression()
Returns:
wicket key expression

getKey

public Key<U,T> getKey()
Get the Key


appendCssClass

protected void appendCssClass(org.apache.wicket.Component value,
                              U ujo)
Append a CSS class - to overwriting only


toString

public String toString()
Domain class + key

Overrides:
toString in class Object

of

public static <U extends Ujo,T> KeyColumn<U,T> of(Key<U,T> key,
                                                  boolean sorted)
A factory method


of

public static <U extends Ujo,T> KeyColumn<U,T> of(Key<U,T> key,
                                                  boolean sorted,
                                                  String cssClass)
A factory method


of

public static <U extends Ujo,T> KeyColumn<U,T> of(Key<U,T> key,
                                                  Key<U,T> sort,
                                                  String cssClass)
A factory method



Copyright © 2015. All Rights Reserved.