You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by Mahi maheshwari <ma...@gmail.com> on 2022/01/20 05:52:07 UTC
How to pull data from the tables and display that data into ftl files
Hi,
I have few ftl files which are dashboards in my plugin.
these ftl files has forms, text boxes and buttons in it. my requirement is
to fetch the data from the tables(only required columns) and show that
table data in the text boxes of ftl page.
for example : I have a text box with label product name in the ftl page .I
want to display the product name by fetching the data from the product
table.
can anyone suggest me how can I achieve this?
Thank you,
Best regards,
Maheshwari.
Re: How to pull data from the tables and display that data into ftl files
Posted by Aditya Sharma <ad...@apache.org>.
Hello Mahi,
You could use EntityQuery in ftl.
Refer below code:
https://github.com/apache/ofbiz-plugins/blob/trunk/projectmgr/template/project/EditTaskAndAssoc.ftl#L94
HTH
Thanks and Regards,
Aditya Sharma
On Thu, Jan 20, 2022 at 11:22 AM Mahi maheshwari <ma...@gmail.com>
wrote:
> Hi,
>
> I have few ftl files which are dashboards in my plugin.
> these ftl files has forms, text boxes and buttons in it. my requirement is
> to fetch the data from the tables(only required columns) and show that
> table data in the text boxes of ftl page.
> for example : I have a text box with label product name in the ftl page .I
> want to display the product name by fetching the data from the product
> table.
>
> can anyone suggest me how can I achieve this?
>
> Thank you,
> Best regards,
> Maheshwari.
>
Re: How to pull data from the tables and display that data into ftl files
Posted by Benjamin Jugl <be...@ecomify.de>.
Hi Maheshwari,
you can assign groovy-scripts to the screen. To do so, you have to set
up your screen like this:
<screen name="your-screen">
<section>
<actions>
<script
location="component://your-path-to-groovy/YourGroovyFile.groovy"/>
</actions>
<widgets>
<platform-specific>
<html>
<html-template
location="component://your-path-to-ftl/YourFtl.ftl"/>
</html>
</platform-specific>
</widgets>
</section>
</screen>
in the script you can use Worker-methods or query-strings to fetch the
data you want to display. Write those to context-variables and you can
use them in the ftl.
You can find plenty of examples in the applications, like the
"Contact"-Screen in "ProfileScreens.xml" and its usage of
"GetContactMechs.groovy".
This one fetches one entity, but you can also use lists of entities.
Have fun exploring, all good wishes and best regards,
Benjamin
Am 20.01.22 um 06:52 schrieb Mahi maheshwari:
> Hi,
>
> I have few ftl files which are dashboards in my plugin.
> these ftl files has forms, text boxes and buttons in it. my requirement is
> to fetch the data from the tables(only required columns) and show that
> table data in the text boxes of ftl page.
> for example : I have a text box with label product name in the ftl page .I
> want to display the product name by fetching the data from the product
> table.
>
> can anyone suggest me how can I achieve this?
>
> Thank you,
> Best regards,
> Maheshwari.
>