PDA

View Full Version : gwt ckeditor in collapsible panel problem



cirkovic
23 Jan 2012, 2:20 PM
I use gwt-ckeditor in layout container in window.
When window collapse and then return to its previous size, ckeditor is inactive and all text is cleared.
Does somebody know why this is happening and how to solve it..

This is picture before collapsing or minimising window
30924

and this is after
30925

Thanks in advance!

harun
24 Jan 2012, 8:12 AM
I have the same problem. it is absolutely GXT desktop application fault. when you minimized then maximized the window new instance coming. I couldn't solve. maybe someone knows problem...

Sven can solve this problem....

cirkovic
24 Jan 2012, 9:28 AM
You helped me with that information!
Found a solution! You just need to disable ckeditor while window is inactive ;)

For collapse and restore (if you have collapse button on your window) add those handlers


addListener(Events.BeforeCollapse, new Listener<BaseEvent>() {

@Override
public void handleEvent(BaseEvent e) {
getCkEditor().setDisabled(true);
}
});


addListener(Events.Expand, new Listener<BaseEvent>() {


@Override
public void handleEvent(BaseEvent e) {
getCkEditor().setDisabled(false);
}
});




For minimize and restore (Restore event activates only when windows was maximised, so you have to use Show)


addListener(Events.Minimize, new Listener<BaseEvent>() {


@Override
public void handleEvent(BaseEvent e) {
getCkEditor().setDisabled(true);
}
});


addListener(Events.Show, new Listener<BaseEvent>() {


@Override
public void handleEvent(BaseEvent e) {
getCkEditor().setDisabled(false);
}
});

Colin Alworth
24 Jan 2012, 10:25 AM
The GXT 'bug' has to do with how the Window is handled when it is not shown. The hide() method on Window removes it from the dom to prevent any leaked memory, and show() adds it again, which causes the iframe to be loaded again.

Generally, as cirkovic found, whatever you are loading should have some way of storing its state.

If you have no such way, then hide() and show() are not for you - use styling to hide and show the window instead. You will need to manually remove the window from the dom when finished with it.

Edit: one other option that should work is subclassing the Window and assigning removeFromParentOnHide to false. I haven't tested this, but it appears that this will prevent the window from being removed, and the frame from being reloaded.