RE: Liferay 7.2 - Portlet - Add options to configuration.json

Marta Santos, modified 6 Years ago. New Member Posts: 22 Join Date: 3/21/17 Recent Posts
Hello everyone,I am creating a react portlet and I want to add some inputs to its configurations.I know how to add fields in the configuration.json file, like a select with a pre-defined set of options. But I wanted to add an input with a dynamic set of values. For instance, an input where the options are the list of folders in the documents and media.Is that possible? How can I do that?Can anyone help me with this? Thank you in advanced.Best regards,Marta Santos
thumbnail
Christoph Rabel, modified 6 Years ago. Liferay Legend Posts: 1555 Join Date: 9/24/09 Recent Posts
Well, we usually use a rest service that provides the data. I am not too familiar with react, but it is usually rather easy to connect a rest endpoint to a component.
So, you could create a new module project of type "Rest" and it will provide you an example rest service. In that rest service you can then e.g. read list of folders or anything else you fancy.
In your react portlet you can then consume that rest service.
You could also try to use the /api/jsonws services but I would advise against it. They are often inconvenient to use and sooner or later you will need to create your own services anyway since the standard interfaces are too unflexible.
Note: There is als the new hypermedia rest api. I had no time to look into it, but it should also enable you to fetch alot of data from the backend using it. Maybe it already has the methods you need.