0

In moqui, how to I include section of screen in *.ftl file. I tried to use <#include "component://path-to-screen"> but nothing happen. In ofbiz, I can use this pattern:

${screens.render("component://common/widget/CommonScreens.xml#myScreen")}

What is the similar pattern in moqui???

kieuanhvu
  • 98
  • 10
  • not sure am right or wrong. you have to give .ftl at end of file name. Go through this link(https://web.liferay.com/web/allen.ziegenfus/blog/-/blogs/working-with-json-in-freemarker ) you may get more idea here. – Sujatha May 11 '18 at 07:39
  • @Sujatha: Ex, I have screen.xml file and in this file I define section named "
    ....
    " and in my *.ftl file I want to include this **includeSection** section. How to I do that? – vu anh kieu just now edit
    – kieuanhvu May 11 '18 at 09:10

1 Answers1

0

In Moqui XML Screens all XML elements are implemented using FTL macros. For HTML output you can see the default (OOTB) macros in the runtime/template/screen-macro/DefaultScreenMacros.html.ftl file. The XML element used to include sections of other screens is section-include. Because there are no Java/Groovy classes that handle XML screen elements you can see everything in the macros.

In this case the Moqui API call in question is on the ScreenRenderImpl class which is available in screens as they render in the 'sri' variable. Here is the relevant line from the screen-include FTL macro:

${sri.renderSection(.node["@name"])}

The renderSection() method takes a String argument with the name of the section in the current screen or the fully qualified screen location plus a hash and the section name as in your example.

David E. Jones
  • 1,721
  • 1
  • 9
  • 8
  • @ Davide E Jone : you mean, I can use code like this: `${sri.renderSection("component://screen/myScreen.xml#includeSection")}`??? – kieuanhvu May 12 '18 at 08:23