Mastering Data Modeling with Liferay Objects

Course Overview

Displaying Lists of Object Entries in Site Pages

Displaying multiple object entries in a single page is a common application requirement, and Clarity's apps are no exception. By default, Liferay automatically generates a basic object view and widget for displaying entries in a table. You've also learned how you can create custom views that define the table's columns. However, these features have limited design options and are best suited for proof of concept and basic administrative interfaces.

To create more robust and user-centric displays, you should leverage Liferay's page builder tools. These tools provide the flexibility and functionality necessary for designing seamless, engaging, and intuitive interfaces. Clarity wants to use these capabilities to design pages for viewing and managing object entries for their ticketing and distributor apps.

Here you'll learn how to create these interfaces. This process consists of two primary stages:

  • Selecting the object data you want to display.
  • Rendering that data in site pages.

Selecting Object Entries to Display

Liferay offers two primary tools for compiling lists of object entries: Collections and Data Sets. Each tool serves different use cases, providing flexibility in how you select and manage the data you want to display.

Understanding Collections

Collections are sets of content items that you can use to group and filter information. Once defined, you can use the collection multiple times as the data source for fragments and widgets across your site. Liferay automatically generates a collection provider for each published object, grouping the object's items into a collection for display on your pages. Liferay also creates related item collection providers to display object entries in relationship tables. For site-scoped objects, you can also create manual or dynamic collections for the object.

Any changes to a collection automatically propagate to page elements using the collection. By decoupling asset selection from rendering, collections provide a centralized place for managing groups of content. You can further personalize collection variants for specific user segments, tailoring content delivery to different audiences.

Collections provide these benefits:

  • Filter and Personalize Content: Specify criteria, such as tags, categories, or publication dates, to filter and display only relevant items within a collection. This enables you to personalize the content experience for different user groups based on their segments.
  • Manual and Automatic Selection: Group content items manually by selecting individual items, or dynamically by defining selection criteria to choose items automatically.
  • Decoupled Data Display: With separate data sourcing, collections provide flexible options to adapt data presentation through collection display fragments, collection pages, and client extensions.
The Collections with Search Blueprints beta feature leverages Liferay's search capabilities to filter, sort, and display object entries based on advanced search criteria. This is especially useful for displaying instance-scoped objects in a site, where manual and dynamic collections are not available. See Collections with Search Blueprints for more information.

Collections with Search Blueprints is currently a beta feature in active development. Do not use beta features in production environments.

Understanding Data Sets

Data sets offer an advanced solution for managing, displaying, and interacting with data across different Liferay resources. They act as virtual repositories, aggregating data from multiple sources and enabling you to create detailed views. This makes them particularly well-suited for scenarios requiring complex data management and interaction.

Key data set features include:

  • Data Aggregation: Gather and centralize data from multiple sources (e.g., objects, blog posts, documents), creating a unified view for reporting and content management.
  • Customizable Views: Tailor data presentation by selecting specific fields to display, defining sorting rules, and applying custom filters to streamline navigation and presentation.
  • Multiple Visualization Modes: Order fields and determine how they render in the data set manager, choosing from available visualization modes: table, list, and card.
  • Interactive Data Set Actions: Direct integration with object entries provides configurable actions (Async, Headless, Link, Modal, and Side Panel) for users to interact with or create items directly.

Datasets are ideal for complex scenarios involving multi-source integration, custom display options, and user interaction with entries.

Data Sets is a beta feature in active development. Do not use beta features in production environments.

Choosing the Right Tool for Entry Selection

When deciding whether to use collections or data sets, consider the complexity of the data, the level of interaction required, and the customization needed:

  • Collections: Collections ideal for simple, straightforward entry displays, particularly when basic filtering, pagination, and relationship data are sufficient (e.g., to display a product list on a category page using dynamic, manual, or automatic collections).
  • Data Sets: Data sets are ideal for scenarios requiring direct user interaction with object entries, such as: data editing, deletion, or the addition of new entries. They're also suited for advanced use cases involving multiple data sources, complex reports, and customized displays. Here are some examples:
    • Generating reports combining data from various departments.
    • Creating dynamic dashboards with different visualizations for different data types.
    • Offering users the ability to perform CRUD (create, read, update, delete) operations directly within the data set interface.

Displaying Lists of Object Entries

Once data is collected, it needs to be displayed. When designing object UIs, it's essential for the displayed data to be intuitive, accessible, and functional. Liferay provides a variety of page builder tools for rendering lists of object entries in a user-friendly way:

  • Collection Display Fragments
  • Data Set Views
  • Asset Publishers
  • Client Extensions
  • Information Templates
  • Display Page Templates
  • Collection Pages

For most use cases, you should use fragments to render collection items, but you can evaluate using data sets, client extensions, or the asset publisher widget for use cases that require complex templating.

Rendering Collections

Liferay objects support all collection display features for rendering lists of entries in site pages. These features include filtering, styling, and display options within fragments and widgets. The Collection Display fragment is one such out-of-the-box fragment. With it, you can easily display entry lists in any content page, page template, or display page.

Similarly, collection pages are a type of page directly linking to an existing collection, simplifying the task of rendering collections.

Collections streamline content presentation. Embed collections into your Liferay site using Liferay's page builder features to showcase curated content within your website layouts. This flexibility allows you to design elegant solutions to display contextualized content.

Best Practices for Rendering Collections

Collections provide a flexible and efficient way to display lists of object entries. They are particularly well-suited for these use cases:

  • Simple Lists and Grids: Use collections to create straightforward lists or grids of object entries, such as displaying a list of applications or evaluations
  • Objects with Relationships: For objects with relationship tables, leverage nested collection display fragments to display multiple related entries. This enables you to present hierarchical or interconnected data clearly and effectively.

Rendering Data Sets

With data sets, you can aggregate data from different sources. This enables you to streamline content management and reporting requirements while implementing unified and informative displays. Using the out-of-the-box data set fragment, you can display data sets directly in site pages and enable users to execute actions defined within the data set, such as:

  • Opening modal windows for user interaction without navigating away from a page.
  • Displaying confirmation or success, failure, or warning messages before executing an action.
  • Providing a method to perform CRUD operations directly within the data set view.

Implementing Clarity's Apps

So far, you've used object views for displaying lists of object entries. While sufficient for basic administrative processes, Clarity wants to leverage collections to create more integrated and flexible displays for their apps. This process involves creating a dedicated page for each object, adding a collection display fragment, and mapping it to the object's auto-generated collection provider. Additionally, Clarity can incorporate collection filter and search fragments to enable users to quickly locate specific entries.

Clarity can incorporate collection filter and search fragments to enable users to quickly locate specific entries.

Clarity's ticketing app will also leverage collections to display ticket data in their sites. To cater to the needs of both customers and support workers, Clarity wants to create distinct ticketing experiences that promote efficient data retrieval. However, these collection displays do not satisfy all of Clarity's entry display requirements. For example, their ticketing app requires an advanced kanban view to help support team members track and manage ticket progress. Clarity can implement this using frontend client extensions.

Conclusion

Liferay provides powerful methods to select and render lists of object entries. By decoupling data sourcing from display with collections, you can easily adapt your data to various contexts. Collections offer a flexible foundation for many data display scenarios, including simple list views and basic filtering. Data sets provide advanced capabilities for complex scenarios displaying lists, such as multi-source integration and custom display options requiring user interaction with entries. By choosing the right approach based on project requirements, you can effectively balance usability, performance, and design flexibility in presenting your lists of Liferay Objects.

Next, you'll display lists of object entries using collections.

  • Selecting Object Entries to Display

  • Displaying Lists of Object Entries

  • Implementing Clarity's Apps

  • Conclusion

Loading Knowledge

Capabilities

Product

Education

Contact Us

Connect

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