Hmm, it should be, but.
My InnerComponent is declared just as You mentioned (not static but, I tried static modifier also)
If I grab inner component rootNode and attach it to the MainView rootNode like this:
getRootNode().setRight(getModel().getInnerComponent(WorkbenchModel.PROPERTIES).getRootNode());
then inner component is not shown. It's method doShow() is not called.
This is OK for simple UI management where all of UI tree is constructed in initView(), but in my case I have the model and view that is dynamic constructed in
start() and reload() methods in view, it is not working.
If I call model.callCommand(AttachModelCommand.class,displayWaveBean) then inner component is shown.
In either case the problem is that when I detach this inner's component rootNode from main view, the inner component is released.
In word released I don't think to released from memory but model's method release is called. After that this inner component loose it's reference to local facade and to getKey.
When lifecyle do it's job, main model is released and all inner components get released also.
In that case exception is thrown because inner component was already released.
Error is thrown in AbstractComponent line 555
getLocalFacade().unregister(getKey());
because getLocalFacade() on already released model is null.
This happens in either case
- inner node is attached like: getRootNode().setRight(getModel().getInnerComponent(WorkbenchModel.PROPERTIES).
and detached like: getRootNode().setRight(null); - inner node is attached like: model.callCommand(AttachModelCommand.class,displayWaveBean)
and detached like: model.callCommand(DetachModelCommand.class,displayWaveBean)
The reason of this is in prepare method of AbstractView// Allow to release the model if the root business object doesn't exist anymore
getRootNode().parentProperty().addListener(new ChangeListener<Node>() {
@Override
public void changed(final ObservableValue<? extends Node> observable, final Node oldValue, final Node newValue) {
if (newValue == null) {
getModel().release();
getRootNode().parentProperty().removeListener(this);
}
}
});
Model's release method is called whenever rootNode loose it's parent. No meter how it is attached to parent like in case 1 or 2
AND AGAIN
Hmm, it should be, but it is not true. Life of inner component ends when it loose it's parent.
It is big problem because after the Error is thrown you can not show any other model even from application menu.
and the biggest problem is you can not close application, main stage is closed but application is still running because there is running thread from AbstractComponent release method.
Tnx for reading.
Currently I have no answer for this problem.