Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
How to retrieve data from DB inside JS File?
Hi,
How to retrieve data from DB inside JS File and how i can implement this?
Thanks in Advance
How to retrieve data from DB inside JS File and how i can implement this?
Thanks in Advance
You are a bit ambiguous here.
1) Do you want to fetch data using javascript in the browser and display it there? In that case, you probably need to use ajax and create a backend rest service (or maybe a portlet with serveResource) that sends you the data.
2) Or do you want to fetch the data in the backend, write it in a page and use it there in javascript?
3) Or do you actually want to write the data in a javascript file? I would advise against that idea, but it is basically the same as option 2.
1) Do you want to fetch data using javascript in the browser and display it there? In that case, you probably need to use ajax and create a backend rest service (or maybe a portlet with serveResource) that sends you the data.
2) Or do you want to fetch the data in the backend, write it in a page and use it there in javascript?
3) Or do you actually want to write the data in a javascript file? I would advise against that idea, but it is basically the same as option 2.
Thanks for your reply.
I created DDL form and storing data in DB. Now i need to generate report using D3.js based on data.
How i can implement this?
I created DDL form and storing data in DB. Now i need to generate report using D3.js based on data.
How i can implement this?
I am not sure here, but I believe you have to read the data using DDLRecordLocalService (or maybe DDLRecordService, in case you need to check permissions)
https://docs.liferay.com/dxp/apps/forms-and-workflow/7.0.6/javadocs/com/liferay/dynamic/data/lists/service/DDLRecordLocalService.html
https://docs.liferay.com/dxp/apps/forms-and-workflow/7.0.6/javadocs/com/liferay/dynamic/data/lists/service/DDLRecordLocalService.html
Yes . I have to call Ddlrecord service but i am not sure how to call that service inside js file?
Any Idea?
Any Idea?
You can't call that service directly from Javascript. Well, that's not exactly true. You can call the DDLRecordService through ajax. You can find the rest service under the path /api/jsonws when you select "ddl" in the dropdown.
I usually found these services rather inconvenient to use. Okish for certain usecases, but inconvenient or insufficient for more complicated usecases.
Alternatively, you could create your own rest services or prepare the data in the backend and write it into the content. e.g. write a portlet, that writes the data to the generated page.
I usually found these services rather inconvenient to use. Okish for certain usecases, but inconvenient or insufficient for more complicated usecases.
Alternatively, you could create your own rest services or prepare the data in the backend and write it into the content. e.g. write a portlet, that writes the data to the generated page.
Hi,
Could you please help me on this?
Thank you
Could you please help me on this?
Thank you
Well, I really like to help, but I can't program that for you. I can point you to the interfaces you need, but I won't do all the work.
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™