I need to create a component that uses the tag title (jcr:title) set in ContentFragment. The tag title cannot be obtained by the core component, so I need to use the TagManagerAPI, in which case I need to write the code in either Java Use-API or Javasciprt Use-API.
I prefer to use Javacript Use-API because I have more experience with Javascript and it requires less code to write. However, Adobe's documentation shows Java Use-API, but Javascript Use-API is only mentioned on some of the pages.
Java Use-API
https://experienceleague.adobe.com/docs/experience-manager-htl/content/java-use-api.html?lang=en
Javascript Use-API
https://experienceleague.adobe.com/docs/experience-manager-htl/content/getting-started.html?lang=en#...
The differences between the APIs are described below, but I wonder if using the Javascript Use-API is not recommended because it is slow and difficult to unit test. I would like to know if there are any problems in using it.
Solved! Go to Solution.
Views
Replies
Total Likes
You can use JavaScript Use API for simple requirements.
Writing code using Java Use API, Sling Models is very simple give a try.
You can use JavaScript Use API for simple requirements.
Writing code using Java Use API, Sling Models is very simple give a try.
@satoshi1 If it is for simple manipulations with the content , then use Javascript API. But ideally all the business logic should go into your Java. In your case, I don't think there should be any issue in using the Javascript for fetching the tag title , if you are confident about it.
Its not about you are more comfortable with Javascript or Java, its about the implementation that too with best practices, and best practice says use Java only in this scenario.
Think about the advantages you will have if you go with JS, apart from your comfortability you are not going to get any thing out of it because AEM ultimately converts that JS to Java( this will make your implementation slow), Getting tagmanager an all are not going to be an easy task to work with in js and as you mentioned, that you can not write test cases for that, this is again going to be a headache for you.
I would say use java only because it is simple, easy and will be based on best practices of the time. Even you know basics of java you can easily write the logic for your requirement.
Hope this helps.
Umesh Thakur
@Anudeep_Garnepudi @Umesh_Thakur @VeenaVikraman
Thank you all for your very helpful input!
I understood that the best practice is to write the logic in Java Use-API.
I would like to try Java Use-API.