Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

118
Visualizações
what is the correct HTL syntax for get the custom attribute in AEM global request object?

I want get the custom attribute in AEM HTL use the request object. this attribute already set to request through javascript use API. like this:

test.js

use(function () {
  request.setAttribute('someKey', 'someValue');
});

test.html

<html data-sly-use.logic="test.js">
<!-- some code ... -->
<body>
  <div>${request.attribute['someKey']}</div>
</body>
</html>

result:

<html data-sly-use.logic="test.js">
<!-- some code ... -->
<body>
  <div></div> <!-- empty -->
</body>
</html>

We can get request attribute without Java? Many thanks.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Since HTL syntax is rather declarative than imperative, calling methods/functions with parameters is not supported. That means you cannot do something like ${request.getAttribute('someKey')}. Unfortunately, the Java HttpServletRequest API does not expose the attributes as a map (it does that for parameters) so you cannot do ${request.attributeMap['someKey']} either, you'll need to fetch the attribute and expose it from your use-object/model.

about 4 years ago · Juan Pablo Isaza Relatório

0

Though you cannot send request attribute the way you are trying to do right now , you can set that as a variable from your server side JS and access it in your code.

In your test.js

use(function () {
   return {
    someKey: someValue
   };
});

In your test.html

<html data-sly-use.logic="test.js">
<!-- some code ... -->
<body>
  <div>${logic.someKey}</div>
</body>
</html>

This should print the someValue as output for you.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda