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

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

public abstract class AbstractPropertyModel<T>
extends Object
implements IChainingModel<T>, IObjectClassAwareModel<T>, 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(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.
 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.
 Object getTarget()
           
protected  Object onGetObject(Component component)
          Deprecated. use getObject() instead
protected  void onSetObject(Component component, Object object)
          Deprecated. use setObject(Object) instead
protected abstract  String propertyExpression()
           
 void setChainedModel(IModel<?> model)
          Sets the model that is chained inside this model.
 void setObject(T object)
          Applies the property expression on the model object using the given object argument.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractPropertyModel

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

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()

getPropertyExpression

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

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>
Parameters:
object - The object that will be used when setting a value on the model object
See Also:
IModel#setObject(T)

toString

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

getTarget

public final Object getTarget()
Returns:
The target 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
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
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
Returns:
Method or null
See Also:
IPropertyReflectionAwareModel.getPropertySetter()

propertyExpression

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

onGetObject

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

Parameters:
component -
Returns:
nothing

onSetObject

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

Parameters:
component -
object -


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