Hi Decebal,

yes, the tree's models should implement equals() and hashcode(). Usually it's sufficient to forward these calls to the wrapped entity. We're doing it this way to allow some optimization: If the model is able to identify an entity by its identifier, then it can shortcut the comparison by comparing the ids instead.

Note that
a) ITreeProvider#model()'s javadoc has a note on implementing these methods
b) model equality is used in IItemReuseStrategy too.

Many thanks for your feedback.
Sven


On 12/11/2013 03:07 PM, Decebal Suiu wrote:
Hi

I write this post for sven as a feedback for his excellent tree component
from wicket 6.
I encounter a problem with the tree component (nothing happens on expand) in
the conversion process of NextReports from wicket 1.5 to wicket 6. My
problem happened because the NestedTree.updateBranch method compares two
model objects (with equals):

  if (model.equals(branch.getModel())) // line 118 in wicket 6.12.0

My EntityModel (the model returned by ITreeProvider.(Entity object)) hasn't
an equals method because I didn't find usefully to implement this method in
my (wicket) models. For this reason the above line return false in all
scenario;

I don't know if it's a better idea to compare the model objects instead
models (I see a little performance with model objects comparation - my
EntityModel extends extends LoadableDetachableModel<Entity>) but in the
current implementation it's hard to debug what it's wrong with my tree.

Obviously, I resolved my problem with a simple equals method added in my
EntityModel but take me some time to found what wasn't wrong with my tree.

Best regards,
Decebal



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Little-issue-with-tree-component-tp4662914.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to