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

java.lang.Object
  extended by org.apache.wicket.model.ChainingModel<T>
      extended by org.apache.wicket.model.AbstractPropertyModel<T>
Type Parameters:
T - The Model object type
All Implemented Interfaces:
Serializable, IChainingModel<T>, IDetachable, IModel<T>, IObjectClassAwareModel<T>, IPropertyReflectionAwareModel<T>, IClusterable
Direct Known Subclasses:
PropertyModel

public abstract class AbstractPropertyModel<T>
extends ChainingModel<T>
implements IObjectClassAwareModel<T>, IPropertyReflectionAwareModel<T>

Serves as a base class for different kinds of property models. By default, this class uses PropertyResolver to resolve expressions on the target model object. Note that the property resolver by default provides access to private members and methods. If guaranteeing encapsulation of the target objects is a big concern, you should consider using an alternative implementation.

Author:
Chris Turner, Eelco Hillenius, Jonathan Locke
See Also:
PropertyResolver, IDetachable, Serialized Form

Constructor Summary
AbstractPropertyModel(Object modelObject)
          Constructor
 
Method Summary
 Object getInnermostModelOrObject()
           
 T getObject()
          Gets the model object.
 Class<T> getObjectClass()
          Returns the class of model object
 String getPropertyExpression()
          Gets the property expression for this model
 Field getPropertyField()
          Returns the field of model property or null if the field doesn't exist.
 Method getPropertyGetter()
          Returns the getter method of model property or null if the method doesn't exist.
 Method getPropertySetter()
          Returns the setter method of model property or null if the method doesn't exist.
protected abstract  String propertyExpression()
           
 void setObject(T object)
          Applies the property expression on the model object using the given object argument.
 
Methods inherited from class org.apache.wicket.model.ChainingModel
detach, getChainedModel, getTarget, setChainedModel, setTarget, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.wicket.model.IDetachable
detach
 

Constructor Detail

AbstractPropertyModel

public AbstractPropertyModel(Object modelObject)
Constructor

Parameters:
modelObject - The nested model object
Method Detail

getObject

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

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

getPropertyExpression

public final String getPropertyExpression()
Gets the property expression for this model

Returns:
The property expression

setObject

public void setObject(T object)
Applies the property expression on the model object using the given object argument.

Specified by:
setObject in interface IModel<T>
Overrides:
setObject in class ChainingModel<T>
Parameters:
object - The object that will be used when setting a value on the model object
See Also:
IModel.setObject(Object)

getObjectClass

public Class<T> getObjectClass()
Description copied from interface: IObjectClassAwareModel
Returns the class of model object

Specified by:
getObjectClass in interface IObjectClassAwareModel<T>
Returns:
model object class

getPropertyField

public Field getPropertyField()
Description copied from interface: IPropertyReflectionAwareModel
Returns the field of model property or null if the field doesn't exist.

Specified by:
getPropertyField in interface IPropertyReflectionAwareModel<T>
Returns:
Field or null
See Also:
IPropertyReflectionAwareModel.getPropertyField()

getPropertyGetter

public Method getPropertyGetter()
Description copied from interface: IPropertyReflectionAwareModel
Returns the getter method of model property or null if the method doesn't exist.

Specified by:
getPropertyGetter in interface IPropertyReflectionAwareModel<T>
Returns:
Method or null
See Also:
IPropertyReflectionAwareModel.getPropertyGetter()

getPropertySetter

public Method getPropertySetter()
Description copied from interface: IPropertyReflectionAwareModel
Returns the setter method of model property or null if the method doesn't exist.

Specified by:
getPropertySetter in interface IPropertyReflectionAwareModel<T>
Returns:
Method or null
See Also:
IPropertyReflectionAwareModel.getPropertySetter()

propertyExpression

protected abstract String propertyExpression()
Returns:
The property expression for the component

getInnermostModelOrObject

public final Object getInnermostModelOrObject()
Returns:
The innermost model or the object if the target is not a model


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