Search code examples
liferayliferay-7

Liferay - populate form of text fields using an external REST service


As a newbie to Liferay I am investigating whether I used the right approach to populate data forms.

When populating a form with a number of text fields using an external REST service, I alraedy implemented the following approaches:

  1. Creating a web content page and fill it with Ajax. Works, but using Jquery is not my preferred (modern) approach for accessing REST services.
  2. Creating a web page using an Angular/React portlet, etc. Also worked for me. As I understand, per page I have to create a small Angular (module) project.
  3. Creating a Form page that retrieves the fields by a data provider. Worked also for me, but this was presentation only.
  4. "Service builders" are used in the examples for working with databases. I did not use this method yet.

Below are a few questions but there only 1 theme: when using Liferay, what are the beste techniques to populate data forms?

  • Is there a better/easier approach in Liferay to fill the form?
  • When using option 3, will it call the data provider multiple times for each field?
  • What if I would like to post the populated form data to the REST service?
  • Which approach is best to fill a table with rows of data?
  • Can/should "service builders" be used for interacting with REST services as well?
  • Is there a way to interact with basic components and Angular? I could not find anything on the internet yet.

Solution

  • I believe that your question is still out of focus for stackoverflow, as it's asking for "the best" way - to that, the answer is a firm "it depends".

    You're listing a couple of options yourself. What you choose will in the end depend on

    • the technology you know
    • the technology you feel comfortable maintaining long term
    • the business requirements - e.g. how flexible to you need to be? can you go low-code, or do you need the full flexibility to develop an actual app
    • how frontend-heavy are your requirements
    • how independent of Liferay do you want them to be?

    That being said: All of your options are good choices in various situations that you need to solve.

    My general recommendation is to think maintenance, and optimize for the future maintenance of your solution, rather than the initial implementation time.

    But, unfortunately, no firm single answer.