{"id":142,"date":"2008-09-15T16:53:19","date_gmt":"2008-09-16T00:53:19","guid":{"rendered":"http:\/\/www.antunkarlovac.com\/blog\/?p=142"},"modified":"2020-02-02T23:57:31","modified_gmt":"2020-02-03T07:57:31","slug":"the-lz-namespace","status":"publish","type":"post","link":"https:\/\/www.antunkarlovac.com\/blog\/2008\/09\/15\/the-lz-namespace\/","title":{"rendered":"The lz Namespace"},"content":{"rendered":"<p>I wrote about <a href=\"\/blog\/2008\/07\/02\/migrating-lzx-code-to-openlaszlo-41\/\">migrating code to OpenLaszlo 4.1<\/a> a while back, but even after a few weeks of working with it, I&#8217;m still getting bitten by the new lz namespace. I&#8217;m just so used to doing things the old way, and this (pretty significant change) is not that well documented, and . Here&#8217;s a summary of the lz namespace, and how it affects LZX code.<\/p>\n<p>Firstly, a general rule: These changes apply to referencing classes in JavaScript and JavaScript expressions in attribute values or constraints only. The way you write tags is unchanged.<\/p>\n<p>For <strong>classes that have a corresponding tag<\/strong>, the new syntax is to use <strong>lz.classname<\/strong>. (Note: all lower case, for LFC classes). This applies to Laszlo Foundation Classes (e.g. <a href=\"http:\/\/www.openlaszlo.org\/lps4.1\/docs\/reference\/LzView.html\" target=\"_blank\">view<\/a>, <a href=\"http:\/\/www.openlaszlo.org\/lps4.1\/docs\/reference\/LzText.html\" target=\"_blank\">text<\/a>), LZX components (e.g. <a href=\"http:\/\/www.openlaszlo.org\/lps4.1\/docs\/reference\/lz.button.html\" target=\"_blank\">button<\/a>, <a href=\"http:\/\/www.openlaszlo.org\/lps4.1\/docs\/reference\/lz.window.html\" target=\"_blank\">window<\/a>) and all classes that you write. These now live in the new <strong>lz<\/strong> namespace:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n\/\/ Old pre-4.1 syntax\r\nvar v = new LzView(canvas, {width: 30, height: 30, bgcolor: red});\r\n\r\n\/\/ New 4.1 syntax\r\nvar v = new lz.view(canvas, {width: 30, height: 30, bgcolor: red});\r\n<\/pre>\n<p>For <strong>classes with no tag<\/strong>, (e.g. <a href=\"http:\/\/www.openlaszlo.org\/lps4.1\/docs\/reference\/LzDelegate.html\" target=\"_self\">LzDelegate<\/a>, <a href=\"http:\/\/www.openlaszlo.org\/lps4.1\/docs\/reference\/LzContextMenu.html\" target=\"_blank\">LzContextMenu<\/a>), the syntax is unchanged, so you would use <strong>LzClassName<\/strong>. These continue to live in the <strong>global<\/strong> namespace:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n\/\/ Old pre-4.1 syntax\r\nvar v = new LzDelegate(this, &quot;doSomething&quot;, this, &quot;onmouseover&quot;);\r\n\r\n\/\/ New 4.1 syntax (unchanged)\r\nvar v = new LzDelegate(this, &quot;doSomething&quot;, this, &quot;onmouseover&quot;);\r\n<\/pre>\n<p>For <strong>services<\/strong> (e.g. LzKeys, LzTimer), there has been some refactoring. The class names are now called <a href=\"http:\/\/www.openlaszlo.org\/lps4.1\/docs\/reference\/LzKeysService.html\" target=\"_blank\">LzKeysService<\/a>, <a href=\"http:\/\/www.openlaszlo.org\/lps4.1\/docs\/reference\/LzTimerService.html\" target=\"_blank\">LzTimerService<\/a>, and they are accessible by the new syntax <strong>lz.Name<\/strong> (note there&#8217;s no &#8220;Service&#8221; suffix to the name).\u00a0 They are in the <strong>lz<\/strong> namespace:<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;!-- Old pre-4.1 syntax --&gt;\r\n&lt;handler name=&quot;onkeydown&quot; reference=&quot;LzKeys&quot; args=&quot;keyCode&quot;&gt;\r\n    Debug.write(&quot;User pressed key: &quot;, keyCode);\r\n&lt;\/handler&gt;\r\n\r\n&lt;!-- New 4.1 syntax --&gt;\r\n&lt;handler name=&quot;onkeydown&quot; reference=&quot;lz.Keys&quot; args=&quot;keyCode&quot;&gt;\r\n    Debug.write(&quot;User pressed key: &quot;, keyCode);\r\n&lt;\/handler&gt;\r\n<\/pre>\n<p><strong>JavaScript classes <\/strong>(e.g. String, Math) are unchanged. They&#8217;re not technically part of the LZX global namespace.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n\/\/ Old pre-4.1 syntax\r\nvar opposite = hypotenuse * Math.sin(angle);\r\n\r\n\/\/ New 4.1 syntax (unchanged)\r\nvar opposite = hypotenuse * Math.sin(angle);\r\n<\/pre>\n<p>These four categories should cover all the possible scenarios you have to deal with as a developer. If you&#8217;re ever in doubt, or want to explore what&#8217;s in the namespaces, enter <em>lz <\/em>or <em>global <\/em>in the Debugger window and click Eval. Then click the blue link that the Debugger returns to serialize the object. You&#8217;ll be able to see all the class names and objects that are in each scope. Once this is done it is only a matter of putting it online on your site, and it should work just fine, great even. Remember however, that for it to have any effect you will need traffic, so you&#8217;ll want to make sure you work with experts to have a good SEO score. Here you can <a href=\"https:\/\/www.tom-johnston.com\/seo-for-franchises\/\">learn more<\/a> about franchise SEO services if you would like to research the topic further. Make sure that you do this sooner rather later so that you can see the effects as soon as possible and get the project rolling!<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>I wrote about migrating code to OpenLaszlo 4.1 a while back, but even after a few weeks of working with it, I&#8217;m still getting bitten by the new lz namespace. I&#8217;m just so used to doing things the old way, and this (pretty significant change) is not that well documented, and . Here&#8217;s a summary &hellip; <a href=\"https:\/\/www.antunkarlovac.com\/blog\/2008\/09\/15\/the-lz-namespace\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">The lz Namespace<\/span><\/a><!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2,3],"tags":[],"_links":{"self":[{"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/posts\/142"}],"collection":[{"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/comments?post=142"}],"version-history":[{"count":5,"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/posts\/142\/revisions"}],"predecessor-version":[{"id":347,"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/posts\/142\/revisions\/347"}],"wp:attachment":[{"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/media?parent=142"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/categories?post=142"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.antunkarlovac.com\/blog\/wp-json\/wp\/v2\/tags?post=142"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}