PDA

View Full Version : ContentPanel.collapse() causes AssertionError



gslender
24 Jun 2008, 8:21 PM
In the current build, ContentPanel.collapse() now causes
java.lang.AssertionError: Method must be called before the component is rendered.

This means you cannot set the before render style of a ContentPanel to be collapsed.

gslender
24 Jun 2008, 8:50 PM
I know why....

ContentPanel has a call to setAnimCollapse(false) in the 3rd last line below.



@Override
protected void afterRender() {
super.afterRender();
if (title != null) {
setHeading(title);
}
if (iconStyle != null) {
setIconStyle(iconStyle);
}
if (collapsed) {
boolean anim = animCollapse;
collapsed = false;
setAnimCollapse(false);
collapse();
setAnimCollapse(anim);
}
}
This call to setAnimCollapse has a check for assertPreRender() which then fails !!

sdc
25 Jun 2008, 4:27 AM
I encountered the same bug with the SVN version. More, I encountered the bug but my ContentPanel was NOT collapsible (I have called setCollapsible(false)).
Actually, in BorderLayout (line 104) you have

Map<String, Object> st = c.getState();
if (st.containsKey("collapsed")) {
switchPanels((ContentPanel) c);State relies on cookies and my cookies contained the collapsed key (because in previous versions of my webapp I could collapse the panel).
Then switchPanels create a new CollapsePanel, the CollapsePanel constructor calls the collapse() method and after render, we have the bug /:).

darrellmeyer
25 Jun 2008, 5:01 AM
This is fixed.