CreateView vs CreateChildView why do I lose my boObject reference?

When you are developing an application using XEO you’ll need to open specific views as a result of certain actions. In order for you to achieve that you need to create the view in memory and for that you have two choices:

XUIViewRoot viewRoot = getSessionContext().createChildView("viewers/path/to/viewer/Viewer.xvw");


XUIViewRoot viewRoot = getSessionContext().createView("viewers/path/to/viewer/Viewer.xvw");

The main difference between the two is regarding the current context. Creating a view with createView uses a new context and switches the context immediately upon invocation (meaning you loose access to anything that was available in the current context) . If you use the createChildView method you maintain the same context in the two views ( which is important if the two views share some relationship – hence the name create ” child ” view)

So if your two views have no relationship but you need information for the current context… Save them in variables before creating the view – or else. Most of the times createChildView is the correct usage, but if the two views are disconnected, use createView.

Happy coding!

Leave a Reply

Your email address will not be published. Required fields are marked *