PDA

View Full Version : [DUP] AccordionLayoutContainer



madmaxmatze
9 Nov 2011, 9:03 AM
I'm not sure if the AccordionLayout is still under development - errors included, or if I'm using it totally wrong:

--------------------------------

When I create an AccordionLayout like in
gxt-3.0.0-dp5\examples-src\com\sencha\gxt\explorer\client\layout\AccordionLayoutExample.java
and add it to the west panel of a BorderLayoutContainer, I see the Accordion but I get the following error:


00:16:20,256 [ERROR] Uncaught exception escaped
java.lang.NullPointerException: null
at com.sencha.gxt.widget.core.client.container.BorderLayoutContainer.onInsert(BorderLayoutContainer.java:693)
at com.sencha.gxt.widget.core.client.container.Container.insert(Container.java:380)
at com.sencha.gxt.widget.core.client.container.BorderLayoutContainer.setWestWidget(BorderLayoutContainer.java:370)

----------------------------------

When I later add any other ContentPanel to the Accordion with: [..] con.add(cp5);


Caused by: java.lang.AssertionError: Method must be called before the widget is rendered
at com.sencha.gxt.widget.core.client.Component.assertPreRender(Component.java:1175)
at com.sencha.gxt.widget.core.client.ContentPanel.setCollapsible(ContentPanel.java:348)
at com.sencha.gxt.widget.core.client.container.AccordionLayoutContainer.onInsert(AccordionLayoutContainer.java:206)
at com.sencha.gxt.widget.core.client.container.Container.insert(Container.java:380)
at com.sencha.gxt.widget.core.client.container.InsertResizeContainer.insert(InsertResizeContainer.java:22)
at com.sencha.gxt.widget.core.client.container.Container.add(Container.java:86)

-----------------------------

Furthermore I couldn't figure out how to get the ChildWidgetIndex of the current expanded child.

sven
9 Nov 2011, 9:05 AM
I think your BorderLayoutContainer problem is related to this one which is already fixed: http://www.sencha.com/forum/showthread.php?153395-FNR-Bug-in-BorderLayoutContainer.setXXXWidget(Widget-w)

madmaxmatze
9 Nov 2011, 9:31 AM
Adding layout data to my uibinder definition as in http://www.sencha.com/learn/ext-gwt-3-declarative-markup-with-uibinder/

Did not fix the problem. But hopefully the next release will. What's about the other 2 questions?

sven
9 Nov 2011, 9:33 AM
Did not fix the problem. But hopefully the next release will.

In that case can you please provide a fully working testcase implementing EntryPoint that shows your problem?

sven
9 Nov 2011, 9:36 AM
Furthermore I couldn't figure out how to get the ChildWidgetIndex of the current expanded child.

There is a getter to get the currently active widget. That one you can pass to the getWidgetIndex method

madmaxmatze
9 Nov 2011, 9:56 AM
When I create a simple example, the problem is fixed with adding BorderLayoutData as suggested in the other bug report:


BorderLayoutContainer container = new BorderLayoutContainer();

AccordionLayoutContainer con = new AccordionLayoutContainer();
con.setFill(true);

ContentPanel cp = new ContentPanel();
cp.setAnimCollapse(false);
cp.setHeadingText("Online Users");
con.add(cp);
con.setWidget(cp);

BorderLayoutData northLayoutData = new BorderLayoutData(100);
container.setNorthWidget(con, northLayoutData);

RootLayoutPanel.get().clear();
RootLayoutPanel.get().add(container);


So it seems that adding BorderLayoutData is not fixing this issue when working with uibinder. My code:

<ui:with type="com.sencha.gxt.widget.core.client.container.BorderLayoutContainer.BorderLayoutData" field="westLayoutData" />

<gxtContainer:BorderLayoutContainer>
[..]
<gxtContainer:west layoutData="{westLayoutData}">
</gxtContainer:west>
[..]
</gxtContainer:BorderLayoutContainer>

and

@UiField(provided = true)
BorderLayoutData westLayoutData = new BorderLayoutData(100);

----------------------

Regarding the other issue, can you tell me how the getter is called. I see nothing like .getActiveWidget()


BTW: Thank for the very fast and nice support!

sven
9 Nov 2011, 10:02 AM
Regarding the other issue, can you tell me how the getter is called. I see nothing like .getActiveWidget()



Its called getWidget

madmaxmatze
9 Nov 2011, 10:21 AM
Thanks for the getWidget() hint - works! :)

The other issue is now gone as well. I didn't realized that even with uibinder the BorderLayoutData has to be passed with the container.setNorthWidget() call and not just in the XML.

The last remaining issue, from my initial questions was: java.lang.AssertionError: Method must be called before the widget is rendered
The error happens when I add new Content Panels to the accordion after the according was already created. This is my code:


ContentPanel cp1 = new ContentPanel(appearance);
cp1.setAnimCollapse(false);
cp1.setHeadingText("Test");
accordionContainer.add(cp1);
accordionContainer.setWidget(cp1);

madmaxmatze
10 Nov 2011, 4:19 AM
To test the last issue, please use the following code: (Error occures with click on button)


public class Designer implements EntryPoint {
public void onModuleLoad() {
BorderLayoutContainer container = new BorderLayoutContainer();
container.setWidth(500);
container.setHeight(500);

final AccordionLayoutContainer con = new AccordionLayoutContainer();
con.setFill(true);

ContentPanel cp = new ContentPanel();
cp.setHeadingText("Test 1");
con.add(cp);
con.setWidget(cp);

Button b = new Button("Press here to add a new item to the accordion");
b.addClickHandler(new ClickHandler () {
@Override
public void onClick(ClickEvent event) {
ContentPanel cp1 = new ContentPanel();
cp1.setHeadingText("Test " + (con.getWidgetCount() + 1));
con.add(cp1);
con.setWidget(cp1);
}
});

BorderLayoutData northLayoutData = new BorderLayoutData(100);
container.setWestWidget(con, northLayoutData);
container.setCenterWidget(b, northLayoutData);

RootLayoutPanel.get().clear();
RootLayoutPanel.get().add(container);
}
}

Pro1712
16 Aug 2012, 3:52 AM
Same problem in 3.0.1!
Is there a fix or workaround?

billsalvucci
25 Jun 2013, 11:24 AM
Has this been submitted as a bug or is there something intrinsically incompatible with adding a contentpanel to an according after it has been attached?

I built a data driven AccordionLayoutContainer. When I was mocking the data locally everything worked fine. But when I wired this to the backend, I got the assert error because I am now fetching the data async.

The problem happens when you add the contentpanel to the accordion in this code:

@Override
protected void onInsert(int index, Widget child) {
super.onInsert(index, child);
assert child instanceof ContentPanel : "AccordionLayoutContainer must be ContentPanels";

ContentPanel cp = (ContentPanel) child;
cp.addBeforeExpandHandler(handler);
cp.addExpandHandler(handler);
cp.setCollapsible(true);
cp.setHideCollapseTool(hideCollapseTool);
cp.setAnimCollapse(false);
cp.setTitleCollapse(titleCollapse);
}

the cp.setCollapible does


public void setCollapsible(boolean collapsible) {
assertPreRender();
this.collapsible = collapsible;
}

protected void assertPreRender() {
assert !isOrWasAttached() : "Method must be called before the widget is rendered";
}

protected final boolean isOrWasAttached() {
return eventsToSink == -1;
}

billsalvucci
25 Jun 2013, 12:45 PM
Has this been submitted as a bug or is there something intrinsically incompatible with adding a contentpanel to an according after it has been attached?

I built a data driven AccordionLayoutContainer. When I was mocking the data locally everything worked fine. But when I wired this to the backend, I got the assert error because I am now fetching the data async.

The problem happens when you add the contentpanel to the accordion in this code:

@Override
protected void onInsert(int index, Widget child) {
super.onInsert(index, child);
assert child instanceof ContentPanel : "AccordionLayoutContainer must be ContentPanels";

ContentPanel cp = (ContentPanel) child;
cp.addBeforeExpandHandler(handler);
cp.addExpandHandler(handler);
cp.setCollapsible(true);
cp.setHideCollapseTool(hideCollapseTool);
cp.setAnimCollapse(false);
cp.setTitleCollapse(titleCollapse);
}

the cp.setCollapible does


public void setCollapsible(boolean collapsible) {
assertPreRender();
this.collapsible = collapsible;
}

protected void assertPreRender() {
assert !isOrWasAttached() : "Method must be called before the widget is rendered";
}

protected final boolean isOrWasAttached() {
return eventsToSink == -1;
}

billsalvucci
25 Jun 2013, 12:49 PM
I commented out the cp.setCollapsible line in onInsert and everything seems to work fine.

This really does seem like a bug in 3.0.1

Colin Alworth
27 Jun 2013, 11:44 AM
This is a bug, not sure why it was passed over when originally mentioned, but there are other reported threads that reference it, so I'm linking this issue to those.

http://www.sencha.com/forum/showthread.php?261470
EXTGWT-3005