net.databinder.models
Class SublistProjectionModel

java.lang.Object
  extended by org.apache.wicket.model.AbstractReadOnlyModel
      extended by org.apache.wicket.model.LoadableDetachableModel
          extended by net.databinder.models.SublistProjectionModel
All Implemented Interfaces:
java.io.Serializable, org.apache.wicket.IClusterable, org.apache.wicket.model.IDetachable, org.apache.wicket.model.IModel
Direct Known Subclasses:
SublistProjectionModel.Chunked

public abstract class SublistProjectionModel
extends org.apache.wicket.model.LoadableDetachableModel

Projects a single list into multiple, arbitrarily transformed sublists without replicating the list structure. A parent list containing sublists is the object wrapped in this model, while the master list model passed in is held and used internally.

If you need to detach the master list, detach this model and the command will be passed to the contained master list. Any action that changes the size of the master list must also detach this model so it can recalculate the sublist count.

Author:
Nathan Hamblen
See Also:
Serialized Form

Nested Class Summary
static class SublistProjectionModel.Chunked
          Breaks the parent list into chunks of the requested size, in the same order as the parent list.
protected  class SublistProjectionModel.ProjectedSublist
          This is a virtual list, a projection of the master list.
static class SublistProjectionModel.Transposed
          Transposes rows and columns so the list runs top to bottom rather than left to right.
 
Constructor Summary
SublistProjectionModel(org.apache.wicket.model.IModel master)
           
 
Method Summary
protected  java.util.List getMasterList()
           
protected abstract  int getParentSize()
           
protected abstract  int getSize(int parentIdx)
           
protected  java.util.List<java.util.List> load()
           
protected  void onDetach()
          Detach master list.
protected abstract  int transform(int parentIdx, int sublistIdx)
           
 
Methods inherited from class org.apache.wicket.model.LoadableDetachableModel
detach, getObject, isAttached, onAttach, toString
 
Methods inherited from class org.apache.wicket.model.AbstractReadOnlyModel
getObject, setObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SublistProjectionModel

public SublistProjectionModel(org.apache.wicket.model.IModel master)
Method Detail

getParentSize

protected abstract int getParentSize()
Returns:
number of sublists

transform

protected abstract int transform(int parentIdx,
                                 int sublistIdx)
Returns:
index of master list mapped to parameters

getSize

protected abstract int getSize(int parentIdx)
Returns:
size sublist at given index

getMasterList

protected java.util.List getMasterList()

load

protected java.util.List<java.util.List> load()
Specified by:
load in class org.apache.wicket.model.LoadableDetachableModel

onDetach

protected void onDetach()
Detach master list.

Overrides:
onDetach in class org.apache.wicket.model.LoadableDetachableModel


Copyright © 2005-2008 Nathan Hamblen. All Rights Reserved.