Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package org.cdlflex.ui.markup.html.repeater.data.table;
 
 import java.util.List;
 
Custom DataTable implementation that extends functionality for ITableAware columns and provides manipulation of rows via IRowCallback. It also allows construction from an ITableSkeleton.

Parameters:
<T> The model object type
<S> the type of the sorting parameter
 
 public class DataTable<T, S> extends org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable<T, S> {
 
     private static final long serialVersionUID = 1L;
 
     private List<IRowCallback<T>> rowCallbacks;

    
Constructor.

Parameters:
id component id
skeleton a table skeleton
 
     public DataTable(String idITableSkeleton<T, S> skeleton) {
         this(idskeleton.getColumns(), skeleton.getDataProvider(), skeleton.getRowsPerPage());
     }

    
Constructor.

Parameters:
id component id
columns list of columns
dataProvider data provider
rows number of rows per page
 
     public DataTable(String idList<? extends IColumn<T, S>> columnsIDataProvider<T> dataProviderlong rows) {
         super(idcolumnsdataProviderrows);
          = new ArrayList<>();
 
         visitColumns(new IVisitor<IColumn<T, S>, Void>() {
             @Override
             public void component(IColumn<T, S> objectIVisit<Voidvisit) {
                 setTable(object);
             }
         });
     }

    
Returns the callbacks that are executed on each created row.

Returns:
the row callbacks
 
     public List<IRowCallback<T>> getRowCallbacks() {
         return ;
     }

    
Adds the given column to the table.

Parameters:
column a column to add
Returns:
this for chaining
 
     @SuppressWarnings("unchecked")
     public DataTable<T, S> addColumn(IColumn<T, S> column) {
         List<IColumn<T, S>> columns = (List<IColumn<T, S>>) getColumns();
         columns.add(column);
         setTable(column);
         return this;
     }

    
Visit the columns of this table.

Parameters:
visitor the visitor
<R> the return type of the visitor
Returns:
visitor return value
    @SuppressWarnings("unchecked")
    public <R> R visitColumns(IVisitor<IColumn<T, S>, R> visitor) {
        return Visits.visitChildren((List<IColumn<T, S>>) getColumns(), visitor);
    }

    
Visit the columns of this table.

Parameters:
visitor the visitor
filter a filter
<R> the return type of the visitor
Returns:
visitor return value
    @SuppressWarnings("unchecked")
    public <R> R visitColumns(IVisitor<IColumn<T, S>, R> visitorIVisitFilter filter) {
        return Visits.visitChildren((List<IColumn<T, S>>) getColumns(), visitorfilter);
    }
    @Override
    protected Item<T> newRowItem(String idint indexIModel<T> model) {
        Item<T> item = super.newRowItem(idindexmodel);
        onAfterCreateRowItem(item);
        return item;
    }
    @Override
    protected Item<IColumn<T, S>> newCellItem(String idint indexIModel<IColumn<T, S>> model) {
        return new DataTableCell<>(idindexmodelthis);
    }

    
Executes the rowCallbacks on the created row item. Called by newRowItem(java.lang.String,int,org.apache.wicket.model.IModel) after the item was created by the superclass.

Parameters:
item the item that was created.
    private void onAfterCreateRowItem(Item<T> item) {
        for (IRowCallback<T> callback : getRowCallbacks()) {
            if (callback != null) {
                callback.call(item);
            }
        }
    }

    
Will call setTable(org.cdlflex.ui.markup.html.repeater.data.table.ITableAware) if the given column is of ITableAware type.

Parameters:
column a column
    protected void setTable(IColumn<T, S> column) {
        if (column instanceof ITableAware) {
            setTable((ITableAware<T, S>) column);
        }
    }

    
Sets this table to the given ITableAware.

Parameters:
tableAware the table aware column to set this table for
    protected void setTable(ITableAware<T, S> tableAware) {
        tableAware.setTable(this);
    }
New to GrepCode? Check out our FAQ X