[
https://issues.apache.org/jira/browse/WICKET-7023?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
leclerc cyril updated WICKET-7023:
----------------------------------
Description:
In NestedTree abstract class (and Maybe in other components or classes) we use
the model comparaison instead of object comparaison (model.getObject()).
In IModel or in LoadableDetachableModel We don't have any equals method defined
(no default, nothing), it will use the default one what is not good.
example (l111) of NestedTree.java in wicket-extensions library
{code:java}
@Override
public void updateBranch(T t, IPartialPageRequestHandler target)
{
final IModel<T> model = getProvider().model(t);
visitChildren(BranchItem.class, new IVisitor<BranchItem<T>, Void>()
{
@Override
public void component(BranchItem<T> branch, IVisit<Void> visit)
{
if (model.equals(branch.getModel()))
{
// BranchItem always outputs its markupId
target.add(branch);
visit.stop();
}
}
});
model.detach();
}{code}
{{}}
Instead of comparing _*model.equals(branch.getModel()*_ should we use instead
the object comparaison itself :
Objects.equals{*}_( model.getObject(), branch.getModelObject() )_{*}
_because here model are different and not same ref , it will always return
false ? or i miss something ?_
If not could you explain us why we have to use the model and what to do to make
it work properly ?
Even we use a custom extension of LoadableDetachableModel if we override the
model equals we have to check the state, if state is attached, get the
transient object and compare it, if not attached, compare the unid. Moreover it
is possible in wicket core or other librairies to compare 2 models not attached
(so finally quite ugly equals no ?).
What is the default behaviour of comparing models if we used the default models
in wicket ? because even in wicket models (CompoundPropertyModel for instance
no equals is defined)
was:
In NestedTree abstract class (and Maybe in other components or classes) we use
the model comparaison instead of object comparaison (model.getObject()).
In IModel or in LoadableDetachableModel We don't have any equals method defined
(no default, nothing), it will use the default one what is not good.
example (l111) of NestedTree.java in wicket-extensions library
{code:java}
@Override
public void updateBranch(T t, IPartialPageRequestHandler target)
{
final IModel<T> model = getProvider().model(t);
visitChildren(BranchItem.class, new IVisitor<BranchItem<T>, Void>()
{
@Override
public void component(BranchItem<T> branch, IVisit<Void> visit)
{
if (model.equals(branch.getModel()))
{
// BranchItem always outputs its markupId
target.add(branch);
visit.stop();
}
}
});
model.detach();
}{code}
{{}}
Instead of comparing _*model.equals(branch.getModel()*_ should we use instead
the object comparaison itself :
Objects.equals{*}_( model.getObject(), branch.getModelObject() )_{*}
If not could you explain us why we have to use the model and what to do to make
it work properly ?
Even we use a custom extension of LoadableDetachableModel if we override the
model equals we have to check the state, if state is attached, get the
transient object and compare it, if not attached, compare the unid. Moreover it
is possible in wicket core or other librairies to compare 2 models not attached
(so finally quite ugly equals no ?).
What is the default behaviour of comparing models if we used the default models
in wicket ? because even in wicket models (CompoundPropertyModel for instance
no equals is defined)
> Problem when comparing model instead of object in NestedTree class
> -------------------------------------------------------------------
>
> Key: WICKET-7023
> URL: https://issues.apache.org/jira/browse/WICKET-7023
> Project: Wicket
> Issue Type: Bug
> Components: wicket-extensions
> Affects Versions: 9.12.0
> Environment: Linux
> Reporter: leclerc cyril
> Priority: Major
>
> In NestedTree abstract class (and Maybe in other components or classes) we
> use the model comparaison instead of object comparaison (model.getObject()).
> In IModel or in LoadableDetachableModel We don't have any equals method
> defined (no default, nothing), it will use the default one what is not good.
> example (l111) of NestedTree.java in wicket-extensions library
> {code:java}
> @Override
> public void updateBranch(T t, IPartialPageRequestHandler target)
> {
> final IModel<T> model = getProvider().model(t);
> visitChildren(BranchItem.class, new IVisitor<BranchItem<T>, Void>()
> {
> @Override
> public void component(BranchItem<T> branch, IVisit<Void> visit)
> {
> if (model.equals(branch.getModel()))
> {
> // BranchItem always outputs its markupId
> target.add(branch);
> visit.stop();
> }
> }
> });
> model.detach();
> }{code}
> {{}}
> Instead of comparing _*model.equals(branch.getModel()*_ should we use instead
> the object comparaison itself :
> Objects.equals{*}_( model.getObject(), branch.getModelObject() )_{*}
> _because here model are different and not same ref , it will always return
> false ? or i miss something ?_
> If not could you explain us why we have to use the model and what to do to
> make it work properly ?
> Even we use a custom extension of LoadableDetachableModel if we override the
> model equals we have to check the state, if state is attached, get the
> transient object and compare it, if not attached, compare the unid. Moreover
> it is possible in wicket core or other librairies to compare 2 models not
> attached (so finally quite ugly equals no ?).
> What is the default behaviour of comparing models if we used the default
> models in wicket ? because even in wicket models (CompoundPropertyModel for
> instance no equals is defined)
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)