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

JavaScript Use-API vs Java Use-API

Avatar

Level 2

Is there any known limitation/restriction on using JavaScript Use-API?

Reading adobe documentation (links below) there is no comparison between the two technologies. 

Do you know something that can't be accomplished by using JavaScript Use-API that would require to use Java Use-API? Is JavaScript Use-API a subset of Java Use-API? Are they fully compatible?

Thank you.

https://docs.adobe.com/docs/en/aem/6-0/develop/sightly/use-api-in-javascript.html

https://docs.adobe.com/docs/en/aem/6-0/develop/sightly/use-api-in-java.html

Please notice that this is NOT a question about: "do you prefer this or that?" or "what is you personal choice?" The purpose of my question is only to know if there are known limitations of JavaScript API over Java API

1 Accepted Solution

Avatar

Correct answer by
Administrator

Hi

As per my understanding, there are no limitation between both.

Documentation Link:- https://docs.adobe.com/docs/en/aem/6-1/develop/sightly.html#Choosing%20The%20Appropriate%20Use%20API

Choosing The Appropriate Use API

Sightly offers two Use API. The following table gives an overview of the pros and cons of each API.

                
 Java Use-APIJavaScript Use-API
Pros
  • faster
  • can be inspected with a debugger
  • easy to unit-test
  • can be modified by front-end devs
  • is located within the component (keeping the view logic of a component close to it's corresponding template)
Cons
  • cannot be modified by front-end devs
  • looks odd when placed within a component
  • slower
  • no debugger (yet)
  • harder to unit-test

For page components, it is recommended to use a mixed model, where all model logic is located in Java, providing clear APIs that are agnostic to anything that happens in the view (i.e. within the components). AEM comes with great default models like the Page or the Resource API that should be able to cover most cases.

All view logic that is specific to a component should be placed within that component as JavaScript, because it belongs to that component.

 

I hope this will help you.

Thanks and Regards

Kautuk Sahni



Kautuk Sahni

View solution in original post

2 Replies

Avatar

Correct answer by
Administrator

Hi

As per my understanding, there are no limitation between both.

Documentation Link:- https://docs.adobe.com/docs/en/aem/6-1/develop/sightly.html#Choosing%20The%20Appropriate%20Use%20API

Choosing The Appropriate Use API

Sightly offers two Use API. The following table gives an overview of the pros and cons of each API.

                
 Java Use-APIJavaScript Use-API
Pros
  • faster
  • can be inspected with a debugger
  • easy to unit-test
  • can be modified by front-end devs
  • is located within the component (keeping the view logic of a component close to it's corresponding template)
Cons
  • cannot be modified by front-end devs
  • looks odd when placed within a component
  • slower
  • no debugger (yet)
  • harder to unit-test

For page components, it is recommended to use a mixed model, where all model logic is located in Java, providing clear APIs that are agnostic to anything that happens in the view (i.e. within the components). AEM comes with great default models like the Page or the Resource API that should be able to cover most cases.

All view logic that is specific to a component should be placed within that component as JavaScript, because it belongs to that component.

 

I hope this will help you.

Thanks and Regards

Kautuk Sahni



Kautuk Sahni