org.apache.wicket.model
Class AbstractPropertyModel

java.lang.Object
  extended by org.apache.wicket.model.AbstractPropertyModel
All Implemented Interfaces:
java.io.Serializable, IClusterable, IChainingModel, IDetachable, IModel, IObjectClassAwareModel, IPropertyReflectionAwareModel
Direct Known Subclasses:
PropertyModel

public abstract class AbstractPropertyModel
extends java.lang.Object
implements IChainingModel, IObjectClassAwareModel, IPropertyReflectionAwareModel

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(java.lang.Object modelObject)
          Constructor
 
Method Summary
 void detach()
          Unsets this property model's instance variables and detaches the model.
 IModel getChainedModel()
          Returns the chained model if there is a chained model.
 java.lang.Object getObject()
          Gets the model object.
 java.lang.Class getObjectClass()
          Returns the class of model object
 java.lang.String getPropertyExpression()
          Gets the property expression for this model
 java.lang.reflect.Field getPropertyField()
          Returns the field of model property or null if the field doesn't exist.
 java.lang.reflect.Method getPropertyGetter()
          Returns the getter method of model property or null if the method doesn't exist.
 java.lang.reflect.Method getPropertySetter()
          Returns the setter method of model property or null if the method doesn't exist.
 java.lang.Object getTarget()
           
protected  java.lang.Object onGetObject(Component component)
          Deprecated. use getObject() instead
protected  void onSetObject(Component component, java.lang.Object object)
          Deprecated. use setObject(Object) instead
protected abstract  java.lang.String propertyExpression()
           
 void setChainedModel(IModel model)
          Sets the model that is chained inside this model.
 void setObject(java.lang.Object object)
          Applies the property expression on the model object using the given object argument.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractPropertyModel

public AbstractPropertyModel(java.lang.Object modelObject)
Constructor

Parameters:
modelObject - The nested model object
Method Detail

detach

public void detach()
Unsets this property model's instance variables and detaches the model.

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

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
Returns:
The chained model
See Also:
IChainingModel.getChainedModel()

getObject

public java.lang.Object getObject()
Description copied from interface: IModel
Gets the model object.

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

getPropertyExpression

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

Returns:
The property expression

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
See Also:
IChainingModel.setChainedModel(org.apache.wicket.model.IModel)

setObject

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

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

toString

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

getTarget

public final java.lang.Object getTarget()
Returns:
The target object

getObjectClass

public java.lang.Class getObjectClass()
Description copied from interface: IObjectClassAwareModel
Returns the class of model object

Specified by:
getObjectClass in interface IObjectClassAwareModel
Returns:
model object class

getPropertyField

public java.lang.reflect.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
Returns:
Field or null
See Also:
IPropertyReflectionAwareModel.getPropertyField()

getPropertyGetter

public java.lang.reflect.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
Returns:
Method or null
See Also:
IPropertyReflectionAwareModel.getPropertyGetter()

getPropertySetter

public java.lang.reflect.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
Returns:
Method or null
See Also:
IPropertyReflectionAwareModel.getPropertySetter()

propertyExpression

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

onGetObject

protected final java.lang.Object onGetObject(Component component)
Deprecated. use getObject() instead

Parameters:
component -
Returns:
nothing

onSetObject

protected final void onSetObject(Component component,
                                 java.lang.Object object)
Deprecated. use setObject(Object) instead

Parameters:
component -
object -


Copyright © 2004-2010 Apache Software Foundation. All Rights Reserved.