Développer ma barre des réalisations de la Communauté.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

Cette conversation a été verrouillée en raison de son inactivité. Veuillez créer une nouvelle publication.

RÉSOLU

How to convert/export the AEM page into an experience fragment?

Avatar

Level 4

Hi,

 

Is there a way to render the entire AEM page in an experience fragment? 

 

USE CASE:

 I have a homepage that contains around 10 components. Now, I want to create a replica of the home page in the experience fragment and export it to AT. Since most of my components are tightly coupled and I cannot use the components directly in experience fragment. So, I'm looking for something that will bring the entire HTML DOM for the homepage and render in experience fragment via some custom component. I have tried the below servlet, but I'm getting an internal server error.

 

 

import org.apache.felix.scr.annotations.Reference;

import org.apache.felix.scr.annotations.sling.SlingServlet;

 

import org.apache.sling.api.SlingHttpServletRequest;

import org.apache.sling.api.SlingHttpServletResponse;

import org.apache.sling.api.servlets.SlingSafeMethodsServlet;

import org.apache.sling.engine.SlingRequestProcessor;

 

import com.day.cq.contentsync.handler.util.RequestResponseFactory;

import com.day.cq.wcm.api.WCMMode;

 

import javax.servlet.ServletException;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

 

import java.io.ByteArrayOutputStream;

import java.io.IOException;

import org.slf4j.Logger;

import org.slf4j.LoggerFactory;

 

@SlingServlet(paths={"/bin/customservlet”})

public class AemResourceResolutionServlet extends SlingSafeMethodsServlet {

 

    protected final Logger log = LoggerFactory.getLogger(this.getClass());

 

    @Reference

    private RequestResponseFactory requestResponseFactory;

 

    @Reference

    private SlingRequestProcessor requestProcessor;

 

    @Override

    protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException {

 

 

        String requestPath = "/content/myapp/en/us_en/home";

 

        HttpServletRequest req = requestResponseFactory.createRequest("GET", requestPath);

        log.debug("req..{}", req.getPathInfo());

        WCMMode.DISABLED.toRequest(req);

 

        ByteArrayOutputStream out = new ByteArrayOutputStream();

        HttpServletResponse resp = requestResponseFactory.createResponse(out);

        requestProcessor.processRequest(req, resp, request.getResourceResolver());

    }

}

 

@Vijayalakshmi_S  @VeenaVikraman @Anudeep_Garnepudi @arunpatidar26 @Jörg_Hoh @vanegi 

 

Regards,

Vijay

Sujets

Les sujets facilitent la catégorisation du contenu de la Communauté et vous aident à retrouver le contenu le plus pertinent.

1 solution acceptée

Avatar

Réponse correcte par
Level 9

Hello,

 

Here is couple of options you can try based on your need

 

1. if your home page components are authored inside container like layout/grid or similar then you can convert to experience fragment directly from page.

rush_pawan_0-1617903470643.png

 

But, that will change the content from home to experience fragment now as it will be referenced to experience fragments created. but also do this

        - configure AT cloud service configuration

        - configure OOTB experience fragment template or if you use custom experience frag template to support your component design to display correct when access as experience fragment page, to view correctly going forward for authors

       - configure replication agent for this experience fragment template

       - export it to AT and deliver to home page as exp frag content

      pretty much refer - https://experienceleague.adobe.com/docs/experience-manager-64/authoring/authoring/experience-fragmen...  and https://experienceleague.adobe.com/docs/experience-manager-64/administering/integration/experience-f...

 

this will be long sustaining approach

 

2. else, simple but short term way is to create path to experience frag content after converting them via creating path to actual content similar as Anudeep mentioned earlier

 

Thanks!!

 

Voir la solution dans l'envoi d'origine

2 Replies

Avatar

Community Advisor

@vijays80591732 

Directly hit page(/content/myapp/en/us_en/home.html) from front-end(AJAX) and you will get entire page html as response. You can request for child nodes also(/content/myapp/en/us_en/home/_jcr_content/root/...../xyz.html).

Avatar

Réponse correcte par
Level 9

Hello,

 

Here is couple of options you can try based on your need

 

1. if your home page components are authored inside container like layout/grid or similar then you can convert to experience fragment directly from page.

rush_pawan_0-1617903470643.png

 

But, that will change the content from home to experience fragment now as it will be referenced to experience fragments created. but also do this

        - configure AT cloud service configuration

        - configure OOTB experience fragment template or if you use custom experience frag template to support your component design to display correct when access as experience fragment page, to view correctly going forward for authors

       - configure replication agent for this experience fragment template

       - export it to AT and deliver to home page as exp frag content

      pretty much refer - https://experienceleague.adobe.com/docs/experience-manager-64/authoring/authoring/experience-fragmen...  and https://experienceleague.adobe.com/docs/experience-manager-64/administering/integration/experience-f...

 

this will be long sustaining approach

 

2. else, simple but short term way is to create path to experience frag content after converting them via creating path to actual content similar as Anudeep mentioned earlier

 

Thanks!!