{"id":160,"date":"2012-01-21T21:40:15","date_gmt":"2012-01-21T21:40:15","guid":{"rendered":"http:\/\/www.corrspt.com\/blog\/?p=160"},"modified":"2013-01-21T22:19:01","modified_gmt":"2013-01-21T22:19:01","slug":"createview-vs-createchildview-why-do-i-lose-my-boobject-reference","status":"publish","type":"post","link":"http:\/\/www.corrspt.com\/blog\/2012\/01\/21\/createview-vs-createchildview-why-do-i-lose-my-boobject-reference\/","title":{"rendered":"CreateView vs CreateChildView why do I lose my boObject reference?"},"content":{"rendered":"<p>When you are developing an application using XEO you&#8217;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:<br \/>\n<code><br \/>\nXUIViewRoot viewRoot = getSessionContext().createChildView(\"viewers\/path\/to\/viewer\/Viewer.xvw\");<br \/>\n<\/code><br \/>\nor<\/p>\n<p><code> XUIViewRoot viewRoot = getSessionContext().createView(\"viewers\/path\/to\/viewer\/Viewer.xvw\");<br \/>\n<\/code><\/p>\n<p>The main difference between the two is regarding the current context. Creating a view with <em>createView<\/em> uses a new context and switches the context <strong>immediately<\/strong> upon invocation (<strong>meaning you loose access to anything that was available in the current context<\/strong>) . If you use the <em>createChildView<\/em> method you maintain the same context in the two views ( which is important if the two views share some relationship &#8211; hence the name create &#8221; child &#8221; view)<\/p>\n<p>So if your two views have no relationship but you need information for the current context&#8230; Save them in variables before creating the view <em>&#8211; or else<\/em>. Most of the times <em>createChildView<\/em> is the correct usage, but if the two views are disconnected, use <em>createView<\/em>.<\/p>\n<p>Happy coding!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When you are developing an application using XEO you&#8217;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 &hellip; <a href=\"http:\/\/www.corrspt.com\/blog\/2012\/01\/21\/createview-vs-createchildview-why-do-i-lose-my-boobject-reference\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,3],"tags":[45,44],"class_list":["post-160","post","type-post","status-publish","format-standard","hentry","category-java","category-xeo","tag-java","tag-xeo"],"_links":{"self":[{"href":"http:\/\/www.corrspt.com\/blog\/wp-json\/wp\/v2\/posts\/160","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.corrspt.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.corrspt.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.corrspt.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.corrspt.com\/blog\/wp-json\/wp\/v2\/comments?post=160"}],"version-history":[{"count":7,"href":"http:\/\/www.corrspt.com\/blog\/wp-json\/wp\/v2\/posts\/160\/revisions"}],"predecessor-version":[{"id":192,"href":"http:\/\/www.corrspt.com\/blog\/wp-json\/wp\/v2\/posts\/160\/revisions\/192"}],"wp:attachment":[{"href":"http:\/\/www.corrspt.com\/blog\/wp-json\/wp\/v2\/media?parent=160"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.corrspt.com\/blog\/wp-json\/wp\/v2\/categories?post=160"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.corrspt.com\/blog\/wp-json\/wp\/v2\/tags?post=160"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}