[ https://issues.apache.org/jira/browse/OFBIZ-9258?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
James Yong updated OFBIZ-9258: ------------------------------ Attachment: OFBIZ-9258.patch Uploaded a new patch, as POC. Some points to note: * Only implemented for Text and Text Area fields. * Used a jQuery plugin from https://github.com/dtuite/jquery.populate. License is MIT. * To keep things simple, 2-way binding is left out. So not using Vue JS here. * Also applied OFBIZ-7004 with some modification as the original patch is not usable for trunk. * There is a quick example at EditProductPromo page. To test it, do the following: *# Navigate to Catalog Manager > Promos, and create a Product Promo, if needed. *# Click on a Product Promo to go to the Edit Product Promo page. *# For the purpose of demo, there is a delay of 1 second before text and text area fields are populated. * The following are the changes for EditProductPromo page to allow the form to pull its data from the server: *# In the screen (view-map type = 'screen') that includes the form, we add {code:xml}<set field="excludeData" value="true"/>{code} *# create a new screen (view-map type = 'screenjson') that include the original form, and configure the routing in controller.xml i.e. {code:xml} <request-map uri="EditProductPromoJson"> <security https="true" auth="true"/> <response name="success" type="view" value="EditProductPromoJson"/> </request-map> ... <view-map name="EditProductPromoJson" type="screenjson" page="component://product/widget/catalog/PromoScreens.xml#EditProductPromoJson"/> {code} Note that ‘screenjson’ is a new view-map type. *# Using the new feature made possible from OFBIZ-7004, we write script within the html-template tag to query and populate the form. {code:xml} <platform-specific> <html><html-template location="EditProductPromoScript_1"><![CDATA[ <script type="text/javascript"> <#if excludeData?has_content> if (${excludeData}){ // delay query by 1 sec for demo purposes setTimeout(function(){ jQuery.ajax({ url: "<@ofbizUrl>EditProductPromoJson?productPromoId=${productPromoId}</@ofbizUrl>", type: "get", data: {}, success: function(data){ data2 = jQuery.parseJSON(data); jQuery('form[name="EditProductPromo"]').populate(data2, {resetForm:false}); }, error: function (textStatus, errorThrown) { alert("Error getting the data") } }); }, 1000); } </#if> </script> ]]></html-template></html> </platform-specific> {code} Feedbacks are welcome. > Render form values from pulled data > ----------------------------------- > > Key: OFBIZ-9258 > URL: https://issues.apache.org/jira/browse/OFBIZ-9258 > Project: OFBiz > Issue Type: Improvement > Components: framework > Affects Versions: Upcoming Release > Reporter: James Yong > Assignee: James Yong > Priority: Minor > Attachments: OFBIZ-9258.patch, OFBIZ-9258.patch > > > Currently, form data is being rendered together with the form widgets. To > better facilitate the use of Single Page or Mobile Application in the future, > it would be better to let the form widgets pull data from the server instead. > An initial discussion was made at > http://ofbiz.135035.n4.nabble.com/Render-table-rows-from-pulled-data-td4703142.html -- This message was sent by Atlassian JIRA (v6.3.15#6346)