Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

questions on headless AEM

Avatar

Level 9

so I've always developed in full-stack but decided to investigate the headless model. the Adobe tutorial (click here for link)  is talking about various stuff and I have some questions. 

 

  1. It seems to me content fragments is only useful if the data to be displayed resembles a database table(s) (e.g. Oracle DB)
  2. Content fragments is not useful for generic pages like "about us" or any presentation where the author wants to control the look-and-feel of the public page
  3. What happens if the data is coming from another API. As an example, a Dell Boomi API was created to return a list of products. (I guess what I'm saying is that the source of truth for products is hosted on a different application. I'm guessing you don't have to have the product list as content fragments in AEM as that's duplication and can cause issues if the source and AEM content fragment is not in sync)
  4. Anything else you want to add?

Thanks!

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@jayv25585659 

 

Q. It seems to me content fragments is only useful if the data to be displayed resembles a database table(s) (e.g. Oracle DB)

We have worked with multiple customers to deliver sites via Content Fragments.

For couple of them we had used Hybrid mode, where CF is used for content, website delivered by AEM Sites and GraphQL for delivery by other channels

 

Q. Content fragments is not useful for generic pages like "about us" or any presentation where the author wants to control the look-and-feel of the public page

For headless, presentation is taken care by front-end layer.

If you want to have a say in presentation from AEM, then Experience Fragments would be a better option.

 

Q. What happens if the data is coming from another API. As an example, a Dell Boomi API was created to return a list of products. (I guess what I'm saying is that the source of truth for products is hosted on a different application. I'm guessing you don't have to have the product list as content fragments in AEM as that's duplication and can cause issues if the source and AEM content fragment is not in sync)

We can use Reverse Proxy to direct the requests to the Third-party API. It can be done on dispatcher or CDN level.

 

 

 


Aanchal Sikka

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

@jayv25585659 

 

Q. It seems to me content fragments is only useful if the data to be displayed resembles a database table(s) (e.g. Oracle DB)

We have worked with multiple customers to deliver sites via Content Fragments.

For couple of them we had used Hybrid mode, where CF is used for content, website delivered by AEM Sites and GraphQL for delivery by other channels

 

Q. Content fragments is not useful for generic pages like "about us" or any presentation where the author wants to control the look-and-feel of the public page

For headless, presentation is taken care by front-end layer.

If you want to have a say in presentation from AEM, then Experience Fragments would be a better option.

 

Q. What happens if the data is coming from another API. As an example, a Dell Boomi API was created to return a list of products. (I guess what I'm saying is that the source of truth for products is hosted on a different application. I'm guessing you don't have to have the product list as content fragments in AEM as that's duplication and can cause issues if the source and AEM content fragment is not in sync)

We can use Reverse Proxy to direct the requests to the Third-party API. It can be done on dispatcher or CDN level.

 

 

 


Aanchal Sikka

Avatar

Community Advisor

HI @jayv25585659 ,

Understanding Headless AEM and Content Fragments

Headless AEM allows you to deliver content via APIs, decoupling the content management from the presentation layer. This is particularly useful for multi-channel delivery where the same content needs to be available on websites, mobile apps, IoT devices, and more.

Let's address your specific questions:

  1. Content Fragments Use Case:

    • Content Fragments vs. Database Tables: Content Fragments in AEM are indeed structured content models, similar to database tables. They are best suited for scenarios where you have repeatable, structured content, such as product descriptions, news articles, or blog posts.
    • Generic Pages: For generic pages like "About Us" or other highly stylized presentation pages, you might prefer to use traditional AEM components and templates. Content Fragments are less about controlling the look-and-feel and more about managing the structure and reuse of content across different channels.
  2. External Data Sources (e.g., Dell Boomi API):

    • Integration with External APIs: If your data resides in an external system like Dell Boomi, you don't need to duplicate that data in AEM Content Fragments. Instead, you can use AEM's integration capabilities to fetch data from external APIs on-demand. This ensures that the source of truth remains the external system, and AEM simply consumes this data.

    • Approaches for Integration:

      • Server-Side Integration: Use AEM's Sling Models or servlets to call the external API and fetch the required data.
      • Client-Side Integration: Make API calls directly from the frontend (e.g., React or Angular app) to fetch data and render it on the page.
    • Example: Here's a simplified example of a Sling Model fetching data from an external API:

 

@Model(adaptables = Resource.class)
public class ProductModel {
    @ValueMapValue
    private String apiUrl;

    public List<Product> getProducts() {
        List<Product> products = new ArrayList<>();
        try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
            HttpGet request = new HttpGet(apiUrl);
            HttpResponse response = httpClient.execute(request);
            String jsonResponse = EntityUtils.toString(response.getEntity());
            products = parseProducts(jsonResponse);
        } catch (IOException e) {
            // Handle exception
        }
        return products;
    }

    private List<Product> parseProducts(String jsonResponse) {
        // Parse the JSON response into a list of products
        // Implementation omitted for brevity
    }
}

 

  1. Additional Considerations:

    • Decoupling Content from Presentation: One of the primary benefits of a headless CMS is the separation of content from its presentation. This allows you to manage and update content independently of how it is displayed across different platforms.
    • GraphQL and AEM: AEM now supports GraphQL, providing a powerful way to query content fragments and other structured content. This can simplify the process of fetching only the data you need for your applications.
    • Content Management Workflows: Even in a headless setup, you can still leverage AEM's robust content management workflows, including versioning, approvals, and scheduling.

Summary

  • Content Fragments are ideal for structured, repeatable content, not for highly stylized pages where look-and-feel is crucial.
  • For external data sources, integrate AEM with the external API directly instead of duplicating data in AEM.
  • Decoupling content from presentation offers flexibility and ensures consistency across different platforms.
  • GraphQL support in AEM enhances querying capabilities for headless implementations.

By leveraging these concepts, you can effectively utilize AEM in a headless manner, ensuring efficient content delivery across multiple channels while maintaining robust content management capabilities.