How do we run our code in debug mode in aem. I have a codebase with aem archetype . | Community
Skip to main content
Level 3
October 26, 2023
Solved

How do we run our code in debug mode in aem. I have a codebase with aem archetype .

  • October 26, 2023
  • 2 replies
  • 1065 views

Hi All,

I need to use aem debug feature for testing purpose

I need to see how the java code is invoked in response to the changes in UI side, say a mouseclick.

I need to know how a particular htl class gets a value.

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by EstebanBustamante

Hi


Please check this article which shows step-by-step how to achieve that:
https://experienceleague.adobe.com/docs/experience-manager-learn/cloud-service/debugging/debugging-aem-sdk/remote-debugging.html?lang=en
https://aemgeeks.com/aem-debugging/how-to-start-aem-in-debug-mode/ 

The only thing you need to know is where in your codebase (java classes) to "set a breakpoint", you can know that easily just by checking what "sling model" is invoked from your HTL class, for example:

<!--/* HTL *--> <div data-sly-use.model="com.myproject.models.HelloWorldModel"> <h1 class="cmp-helloworld__title">${model.title}</h1> </div>

In the above line, the java class is HellowWorldModel.java which is under the package "com.myproject.models"

And the value ${model.title} will come from the method "getTitle()" from the model. So you would need to add a breakpoint in the "getTitle()" method from your model once the debugger is started.

 

Hope this helps

 

Learn more about sling models and HTL here: https://experienceleague.adobe.com/docs/experience-manager-learn/getting-started-wknd-tutorial-develop/project-archetype/component-basics.html?lang=en

2 replies

EstebanBustamante
Community Advisor and Adobe Champion
EstebanBustamanteCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
October 26, 2023

Hi


Please check this article which shows step-by-step how to achieve that:
https://experienceleague.adobe.com/docs/experience-manager-learn/cloud-service/debugging/debugging-aem-sdk/remote-debugging.html?lang=en
https://aemgeeks.com/aem-debugging/how-to-start-aem-in-debug-mode/ 

The only thing you need to know is where in your codebase (java classes) to "set a breakpoint", you can know that easily just by checking what "sling model" is invoked from your HTL class, for example:

<!--/* HTL *--> <div data-sly-use.model="com.myproject.models.HelloWorldModel"> <h1 class="cmp-helloworld__title">${model.title}</h1> </div>

In the above line, the java class is HellowWorldModel.java which is under the package "com.myproject.models"

And the value ${model.title} will come from the method "getTitle()" from the model. So you would need to add a breakpoint in the "getTitle()" method from your model once the debugger is started.

 

Hope this helps

 

Learn more about sling models and HTL here: https://experienceleague.adobe.com/docs/experience-manager-learn/getting-started-wknd-tutorial-develop/project-archetype/component-basics.html?lang=en

Esteban Bustamante
aanchal-sikka
Community Advisor
Community Advisor
October 26, 2023
Aanchal Sikka