PDA

View Full Version : weird refresh problem



petko.ivanov
23 Dec 2010, 8:02 AM
hi,
have the following weird problem.
I have a chart controlled with a CheckBoxGroup. When a data update comes, the CheckBoxGroup need to be updated. So i am constructing a new group, and replacing the old one. Here is the code that does the replacing :


@SuppressWarnings("unchecked")
public static boolean replaceDisplayed(Widget remove, Widget insert){
LayoutContainer c = (LayoutContainer) remove.getParent();
List items = c.getItems();
for(int i=0;i<items.size();i++){
if (items.get(i)==remove){
c.insert(insert, i);
c.remove(remove);
c.layout(true);
return true;
}
}
return false;
}
It works as intended in debug mode ie with the gwt browser plugin from debugger, but when i deploy it, it fails. The checkboxes in the group do not affect the chart. If i switch to a different tab and back to this one, everything works. Any theories? It has to be some kind of refresh that gets triggered with the tab switching to fix it, i tried .repaint() and .recalculate() but did not seem to help.
thanks

sven
23 Dec 2010, 8:04 AM
Can you please try to post some small, standalone testcase that implements EntryPoint? The logic you posted here is not sufficient.

petko.ivanov
23 Dec 2010, 8:11 AM
writing a small scale code that illustrates the problem may be harder than the problem itself.
it is just very involved.
at this point i will take any speculation ...
the CheckBoxGroup and Chart are inside a HorizontalPanel (the LayoutContainer in the above function).

sven
23 Dec 2010, 8:15 AM
Try calling on the chart object when you are finished with your checkboxgroup changes.

petko.ivanov
23 Dec 2010, 8:21 AM
yes, i was trying that (i think). calling chart.refresh() did not make a difference.
it just struck me that the problem may not be the chart but the CheckBoxGroup.
So for kicks i added the line :
CheckboxGroup.show()
after .layout() and it seems to work.
weird!

sven
23 Dec 2010, 8:23 AM
So you saying the Chart is refreshing, just not the CHeckBoxGroup?

petko.ivanov
23 Dec 2010, 8:24 AM
spoke too soon.
in addition, sometimes when i shift+reload it just works, so i guess was working because of that.
just loading the URL again does not seem to work.

sven
23 Dec 2010, 8:25 AM
You should really take the time and make a standalone testcase. You have all the coded needed for this, should not be very hard and time comsuming. Just guessing around will take fare more time.

petko.ivanov
23 Dec 2010, 8:27 AM
well, in debug mode everything works.
with compiled code, what i see is that CheckboxGroup seems to be shown correct, when i select/ deselect the check mark changes accordingly but the Chart does not reflect the change.
If i switch tabs, and then CheckBoxGroup changes get reflected.

So you saying the Chart is refreshing, just not the CHeckBoxGroup?

petko.ivanov
23 Dec 2010, 11:54 AM
so the final fix i am going in as as bizarre as the issue. Here is what the gui setup :
VerticalPanel (A) contains HorizontalPanel(B) which contains Chart and CheckBoxGroup.
The fix is to put CheckBoxGroup in another VerticalPanel.
everything works, tested it many times as i could not believe it initially. oh well.