{"id":13562,"date":"2014-05-12T14:48:18","date_gmt":"2014-05-12T09:18:18","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=13562"},"modified":"2014-05-12T14:48:18","modified_gmt":"2014-05-12T09:18:18","slug":"change-static-dialog-to-dynamic-without-re-authoring-existing-content","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/change-static-dialog-to-dynamic-without-re-authoring-existing-content\/","title":{"rendered":"Change Static Dialog to Dynamic without re-authoring existing content"},"content":{"rendered":"<p>Almost all the time, we have fields of a component&#8217;s dialog fixed and any change in it requires change in code. I had a use case in which all the fields had to be populated dynamically from a node that had information in its child nodes.<\/p>\n<p><a href=\"\/blog\/wp-ttn-blog\/uploads\/2014\/05\/aa.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-13563\" src=\"\/blog\/wp-ttn-blog\/uploads\/2014\/05\/aa.png\" alt=\"\" width=\"241\" height=\"174\" \/><\/a><\/p>\n<p>Some challenges that I faced was:<\/p>\n<p><span style=\"font-size: 16px\">&#8211; The component was used in lot of places and any change in that would have required re-authoring that I had to avoid.<\/span><br \/>\n<span style=\"font-size: 16px\">&#8211; Showing all the fields on the page as the number of fields was dependent in the content code and that was not fixed.<\/span><\/p>\n<div><span style=\"font-size: medium\"><span style=\"line-height: 24px\"><br \/>\n<\/span><\/span><\/div>\n<p>Solution:<\/p>\n<p><span style=\"font-size: 16px\">&#8211; Change xtype of component to &#8220;cqinclude&#8221;<\/span><br \/>\n<span style=\"font-size: 16px\">&#8211; In path property, path of a servlet is given that returns a JSON for the dialog. Purpose of servlet is to read the content node with which dialog had to be synced and populate it in a JSON. \u00a0To make existing authored components work with it, &#8220;name&#8221; of the existing fields of the dialog has be remain same. That ways, it would pick the authored values in the components and new fields would remain as it is with the default value.<\/span><br \/>\n<span style=\"font-size: 16px\">&#8211; Other problem was to display the values on a jsp. This can be accomplished usign JSTL by simply looping over the properties of the dialog and displaying them.<\/span><\/p>\n<div>[html]<br \/>\n&lt;c:forEach var=&quot;entry&quot; items=&quot;${properties}&quot;&gt;<br \/>\n &lt;c:out value=&quot;${entry.key}&quot;\/&gt;;<br \/>\n &lt;\/c:forEach&gt;<\/p>\n<p>[\/html]<\/p>\n<\/div>\n<p>This could be useful when we are unsure of the properties that we are going to have for a component. For example, if we have a component that is used for information regarding a company and initially we want to store basic things like name, registration id. Later on if we want to add fields like turnover and stock value, that will automatically be available to the author.<\/p>\n<p>Hope this Helps.. \ud83d\ude42<\/p>\n<p>Vivek Sachdeva<br \/>\nCQ5 Developer<br \/>\nin.linkedin.com\/pub\/vivek-sachdeva\/20\/192\/934\/<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Almost all the time, we have fields of a component&#8217;s dialog fixed and any change in it requires change in code. I had a use case in which all the fields had to be populated dynamically from a node that had information in its child nodes. Some challenges that I faced was: &#8211; The component [&hellip;]<\/p>\n","protected":false},"author":48,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":3},"categories":[1],"tags":[4847,258,1207,1425],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/13562"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/48"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=13562"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/13562\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=13562"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=13562"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=13562"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}