Show Menu
TOPICS×

HTL Use-API

The following table gives an overview of the pros and cons of each API.
Java Use-API
JavaScript Use-API
Pros
  • faster
  • can be inspected with a debugger
  • easy to unit-test
  • can be modified by front-end developers
  • 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 developers
  • 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.