You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Pedro Santos (JIRA)" <ji...@apache.org> on 2011/06/14 16:55:48 UTC
[jira] [Commented] (WICKET-3702) wicket:border: inconsistency
between add() and remove()
[ https://issues.apache.org/jira/browse/WICKET-3702?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13049216#comment-13049216 ]
Pedro Santos commented on WICKET-3702:
--------------------------------------
+1 for Martin's patch. Some times it is good to look at AWT API because they probably went through component API design questions like us. JFrame for instance required to get the content panel to add a new component in begining [1]. But its JFrame#add/remove/etc/Impl got changed to delegate to content panel.
frame.getContentPanel().add(newComp) --> frame.add(newCompo)
I see some similarities here.
1 - http://weblogs.java.net/blog/hansmuller/archive/2005/11/jframeadd_conte.html
> wicket:border: inconsistency between add() and remove()
> -------------------------------------------------------
>
> Key: WICKET-3702
> URL: https://issues.apache.org/jira/browse/WICKET-3702
> Project: Wicket
> Issue Type: Bug
> Components: wicket-core
> Affects Versions: 1.5-RC4
> Reporter: Antti S. Lankila
> Assignee: Igor Vaynberg
> Fix For: 1.5-RC5
>
> Attachments: wicket-3702.patch
>
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> Assuming c1 is a Border and c2 is some component, the following sequence crashes with duplicate addition:
> c1.add(c2);
> c1.remove(c2);
> c1.add(c2);
> The reason for this is that remove() doesn't remove the object from the bodycontainer. The sequence can be made to work by changing the middle line to:
> c1.getBodyContainer().remove(c2);
> That remove() doesn't look the component from the same container as add() adds it to, seems to violate the principle of least astonishment. Unfortunately the Component structure manipulation API has more methods, such as swap(), size(), get(), etc. which are final, and can't be overridden by Border as they are. It could be best to force all users to use c1.getBodyContainer().add() instead of c1.add(), because consistent operation is probably easier to deal with in the long run than behavior that conforms to initial assumptions but has flaws elsewhere.
> This ticket suggests removing the overload of add() and documenting the difference in migration guide.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira