org.apache.wicket.model
Class CompoundPropertyModel<T>

java.lang.Object
  extended by org.apache.wicket.model.CompoundPropertyModel<T>
Type Parameters:
T - The model object type
All Implemented Interfaces:
java.io.Serializable, IClusterable, IChainingModel<T>, IComponentInheritedModel<T>, IDetachable, IModel<T>

public class CompoundPropertyModel<T>
extends java.lang.Object
implements IComponentInheritedModel<T>, IChainingModel<T>

A simple compound model which uses the component's name as the property expression to retrieve properties on the nested model object. CompoundPropertyModel is a chaining model so it will call get/setobject on the given object if the object is an instanceof IModel itself.

Author:
Jonathan Locke
See Also:
IModel, Model, LoadableDetachableModel, IChainingModel, Serialized Form

Constructor Summary
CompoundPropertyModel(IModel<T> model)
          Constructor
CompoundPropertyModel(T object)
          Constructor
 
Method Summary
<S> IModel<S>
bind(java.lang.String property)
          Binds this model to a special property by returning a model that has this compound model as its nested/wrapped model and the property which should be evaluated.
 void detach()
          Detaches model after use.
 IModel<?> getChainedModel()
          Returns the chained model if there is a chained model.
 T getObject()
          Gets the model object.
static
<Z> CompoundPropertyModel<Z>
of(IModel<Z> model)
          Type-infering factory method
protected  java.lang.String propertyExpression(Component component)
          Returns the property expression that should be used against the target object
 void setChainedModel(IModel<?> model)
          Sets the model that is chained inside this model.
 void setObject(T object)
          Sets the model object.
 java.lang.String toString()
           
<C> IWrapModel<C>
wrapOnInheritance(Component component)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CompoundPropertyModel

public CompoundPropertyModel(IModel<T> model)
Constructor

Parameters:
model - The model

CompoundPropertyModel

public CompoundPropertyModel(T object)
Constructor

Parameters:
object - The model object
Method Detail

getObject

public T getObject()
Description copied from interface: IModel
Gets the model object.

Specified by:
getObject in interface IModel<T>
Returns:
The model object
See Also:
IModel.getObject()

setObject

public void setObject(T object)
Description copied from interface: IModel
Sets the model object.

Specified by:
setObject in interface IModel<T>
Parameters:
object - The model object
See Also:
IModel.setObject(java.lang.Object)

getChainedModel

public IModel<?> getChainedModel()
Description copied from interface: IChainingModel
Returns the chained model if there is a chained model.

Specified by:
getChainedModel in interface IChainingModel<T>
Returns:
The chained model
See Also:
IChainingModel.getChainedModel()

setChainedModel

public void setChainedModel(IModel<?> model)
Description copied from interface: IChainingModel
Sets the model that is chained inside this model.

Specified by:
setChainedModel in interface IChainingModel<T>
See Also:
IChainingModel.setChainedModel(org.apache.wicket.model.IModel)

detach

public void detach()
Description copied from interface: IDetachable
Detaches model after use. This is generally used to null out transient references that can be re-attached later.

Specified by:
detach in interface IDetachable
See Also:
IDetachable.detach()

propertyExpression

protected java.lang.String propertyExpression(Component component)
Returns the property expression that should be used against the target object

Parameters:
component -
Returns:
property expression that should be used against the target object

wrapOnInheritance

public <C> IWrapModel<C> wrapOnInheritance(Component component)
Specified by:
wrapOnInheritance in interface IComponentInheritedModel<T>
Type Parameters:
C - the model object type of the wrapped model
Returns:
The WrapModel that wraps this model
See Also:
IComponentInheritedModel.wrapOnInheritance(org.apache.wicket.Component)

bind

public <S> IModel<S> bind(java.lang.String property)
Binds this model to a special property by returning a model that has this compound model as its nested/wrapped model and the property which should be evaluated. This can be used if the id of the Component isn't a valid property for the data object.

Type Parameters:
S - the type of the property
Parameters:
property -
Returns:
The IModel that is a wrapper around the current model and the property

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

of

public static <Z> CompoundPropertyModel<Z> of(IModel<Z> model)
Type-infering factory method

Type Parameters:
Z -
Parameters:
model - model
Returns:
CompoundPropertyModel instance


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.