[
https://issues.apache.org/jira/browse/WICKET-3496?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Alexander Morozov updated WICKET-3496:
--------------------------------------
Attachment: myproject.7z
> Component#setDefaultModelObject should take in account IWrapModel
> ------------------------------------------------------------------
>
> Key: WICKET-3496
> URL: https://issues.apache.org/jira/browse/WICKET-3496
> Project: Wicket
> Issue Type: Improvement
> Components: wicket-core
> Affects Versions: 1.4.16
> Environment: Win7, JDK 1.6u23, Jetty 6
> Reporter: Alexander Morozov
> Attachments: myproject.7z
>
>
> Under some conditions, component's model object will not be updated (2),
> because
> of Component#defaultModelComparator (1). One of such kind of condition is
> default model that implements
> IWrapModel (see quickstart).
> Component#setDefaultModelObject:
> // Check whether this will result in an actual change
> if (!getModelComparator().compare(this, object)) //<<<<< 1
> >>>>>>
> {
> modelChanging();
> model.setObject(object); //<<<<< 2 >>>>>>
> modelChanged();
> }
> I suggest that defaultModelComparator can be slightly improved to be able to
> extract and compare the real ("unwrapped") object,
> for example, by means of Component#getInnermostModel():
> Component#defaultModelComparator:
> private static final IModelComparator defaultModelComparator = new
> IModelComparator()
> {
> private static final long serialVersionUID = 1L;
> public boolean compare(Component component, Object b)
> {
> // final Object a = component.getDefaultModelObject();
> //<<<<< 3 >>>>>>
> IModel<?> model = component.getInnermostModel(); //
> get "real" model
> final Object a = model.getObject();
> if (a == null && b == null)
> {
> return true;
> }
> if (a == null || b == null)
> {
> return false;
> }
> return a.equals(b);
> }
> };
--
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira