Mastering Data Modeling with Liferay Objects

Course Overview

Creating and Managing Object Definitions

So far, you’ve explored the foundational principles of data modeling with Liferay Objects. Here, you’ll explore the practical aspects of creating and managing object definitions, starting with an overview of the Objects UI. To access it, open the Global Menu, go to the Control Panel tab, and click Objects.

Users can choose between two interfaces for creating and managing object definitions: the Default Object Editor or the Model Builder. The default editor provides an administrative interface for configuring and extending every aspect of an individual object definition. In contrast, the model builder offers an Entity Relationship Diagram (ERD) for efficiently creating, configuring, adding fields to, and relating multiple object definitions.

Using the Default Object Editor UI

The default object editor displays object definitions in a table view. From here, you can create, view, and edit any object definition in your instance, including system objects. When working on solutions that include multiple object definitions, you can create folders to group them together. This can help improve organization while also streamlining permissions management.

When editing an object definition, the default interface organizes options into separate tabs.

Tab Purpose
Details Edit the object definition’s core configurations, including name and scope.
Fields Add, manage, and configure the object definition’s fields, which determine the type of data stored in the object’s database tables.
Relationships Add, manage, and configure the object definition’s relationships, which enable you to link object entries.
Layouts Graphically define the object’s form for creating and editing entries; this form is used by the object’s widget.
Actions Define custom actions that execute on object entries and are triggered by user interactions or system events.
Views Graphically define the object’s table for displaying existing entries; this table is used by the object’s widget.
Validations Define field-level validations for user input to ensure data integrity and consistency.
State Manager Define valid state transitions for the object’s custom state fields.

 

This interface is best for focused, detailed work on individual object definitions. However, when managing solutions with multiple objects, the Model Builder UI provides a superior user experience.

Using the Model Builder GUI

The Model Builder GUI displays each object definition as a card and visualizes relationships between object definitions. With it, you can create, manage, and extend data models in the Objects application and quickly configure definitions, fields, and relationships.

This interface is great for quickly configuring multiple object definitions and their attributes. It is especially helpful for visualizing and managing object relationships. However, some configuration options (e.g., actions, validations) are only available via the default object editor.

Organizing Object Definitions with Folders

By default, Liferay includes a single folder for all system and custom object definitions. However, it’s best practice to create your own folders for organizing definitions. You can do this via the default object editor by clicking Add Folder.

To improve management, categorize your object definitions by application using these folders. For example, Clarity should use separate folders for their distributor and ticketing apps. Once created, you can add object definitions to them using either the default object editor UI or model builder GUI.

Creating Draft Object Definitions

Implementing solutions with Liferay Objects begins with creating draft object definitions for your data entities. These drafts serve as templates for your object applications, defining their structure and behavior.

When creating a draft, you determine these key details:

  • Label: Identifies the object in multiple application contexts (e.g., Objects, Workflow, Display Page Templates, Forms).

  • Plural Label: Determines the object's display name in the UI when referring to multiple instances.

  • Object Name: Sets the object’s definition.name, which cannot be changed after publishing.

It's crucial to use clear and descriptive names for your objects, avoiding ambiguity and improving long-term maintainability.

At creation, a draft includes several system fields (e.g., createDate, userId, status), but is otherwise a blank canvas. To complete the object definition, you must configure its properties, add fields, and publish it to your Liferay instance.

Publishing Object Drafts

Publishing an object creates and activates your new application, making it available for use. During the publishing process, Liferay performs these operations:

  • Database Setup: Creates database tables for persisting the object's entries.

  • Application Initialization: Initializes the object application so you can access it and create entries through the Liferay UI.

  • Headless API Generation: Generates dedicated headless APIs for performing create, read, update, and delete (CRUD) operations for the object.

  • Framework Integration: Integrates the object with Liferay's core frameworks (e.g., permissions, info, workflow).

  • Collection Provider Creation: Creates a collection provider for displaying the object's entries in site pages.

  • Widget Provisioning: Adds a page widget for the object, providing a basic, utilitarian UI for managing entries on site pages.

  • Configuration Locking: Locks certain aspects of the object definition (e.g., name, scope) to prevent conflicts.

Once published, you cannot unpublish the an object definition, though you can deactivate or delete it.

Conclusion

Liferay's intuitive UI empowers you to effortlessly create and organize object definitions, streamlining your development workflow. Next, you'll explore object configuration options and best practices.

  • Using the Default Object Editor UI

  • Using the Model Builder GUI

  • Organizing Object Definitions with Folders

  • Creating Draft Object Definitions

  • Publishing Object Drafts

  • Conclusion

Loading Knowledge

Capabilities

Product

Education

Contact Us

Connect

Powered by Liferay
© 2024 Liferay Inc. All Rights Reserved • Privacy Policy