This website uses cookies to ensure you get the best experience. Learn More.
Liferay Object Management
Liferay Objects can generate service layers by simply declaring schema in the Liferay control panel. Liferay makes the Object's content accessible via headless APIs as well. On Notifications with Liferay Objects, I've already written one blog post. I'll go over the fundamentals of objects, mappings, and Layouts in greater depth.
Go to Liferay's control panel and select Objects to create new Liferay objects.
When you click the "Add Object" button, you will be prompted to enter a name for the item. Once finished, click the Save button to create a draft object.
This is able to be edited, and fields could be added to the object.
Liferay will include certain default fields, like "Create Date," "Status," and others. Also, this panel itself lets you define new fields.
These are some of the field types that Liferay objects may support.
You can publish your object once you have finished with the field definitions. But wait for a second…
Choose the object's scope. Since once it is published, it cannot be changed
Publish it now, and boom. For this item, Liferay has developed service layers, a database table, and a REST API.
The object is now available in the portal category you have chosen (in our example, Control Panel > Users and Organizations).
You can manage the entries in these objects from this page.
The /o/api page provides access to Liferay objects' headless APIs. where Section /o/objectName shall contain all APIs linked to the object.
GraphQL Query to fetch the object entries
We will do a one-to-many mapping between Employee and Phone in this example. The quick steps are listed below.
Navigate to edit the “Employee” page
Open the “Relationship” tab, and click on “Add Relationship”
Enter the required details
Click on the save button.
It will add a new field with the name "classPK" to the object "Phone."
Let's define Layout in the object now so that mapping can be seen more clearly.
Add one entry to the Employee object now.
After you are finished, click the save button. Liferay will then update the screen's layout to show the contact information that was previously established in the layout, from which you can see the mapped "Phone" entities.
The most recent version of Liferay will let you add mapping entries right here.
The blog would be extremely long if I listed all the intriguing things we can do with Liferay objects. Let's discuss those in the next blog.