John,
Well spotted. AbstractPropertyModel implements IChainingModel but breaks its
contract :
* Models that implement this interface will support chaining of IModels.
getObject() of a
* IChainingModel should do something like:
*
* <pre>
* if ( object instanceof IModel) { return ((IModel)object).getObject()}
* else return object;
* </pre>
Its getObject() implementation does not abide by this.
/**
* @see org.apache.wicket.model.IModel#getObject()
*/
public Object getObject()
{
final String expression = propertyExpression();
if (Strings.isEmpty(expression))
{
// Return a meaningful value for an empty property
expression
return getTarget();
}
final Object target = getTarget();
if (target != null)
{
return PropertyResolver.getValue(expression, target);
}
return null;
}
Regards - Cemal
http://www.jWeekend.co.uk http://jWeekend.co.uk
John Patterson wrote:
>
> Hi,
>
> I'm messing about with nested models and see the IChainingModel interface
> which is implemented by the PropertyModels but its methods never actually
> seems to be used.
>
> So I'm just checking that I haven't missed anything... for nested models I
> don't actually need to implement this right?
>
> This is its def:
>
>
> public interface IChainingModel<T> extends IModel<T>
> {
> /**
> * Sets the model that is chained inside this model.
> *
> * @param model
> */
> public void setChainedModel(IModel< ? > model);
>
> /**
> * Returns the chained model if there is a chained model.
> *
> * @return The chained model
> */
> public IModel< ? > getChainedModel();
>
> }
>
> Thanks,
>
> John
>
>
>
--
View this message in context:
http://www.nabble.com/IChainingModel-tp20835085p20835745.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]