Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

324
Vistas
JSF 2.3.14: Syntax error after (re-) rendering a JavaScript code block with constants

The following code fragment generates a javascript syntax error when I push the h:commandButton:

<h:outputScript>
  'use strict';
  const label = '*';
</h:outputScript>
<h:form>
  <h:commandButton>
    <f:ajax render="@all" />
  </h:commandButton>
</h:form>

SyntaxError: redeclaration of const label

The problem is the const label = '*'. How to deal with that in this case?

Mojarra 2.3.14

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can make the h:outputScript conditional, based on facesContext.postback. If you use rendered="#{not facesContext.postback}" it will only be rendered in the initial request and not with Ajax requests:

<h:outputScript rendered="#{not facesContext.postback}">
  'use strict';
  const label = '*';
</h:outputScript>
<h:form>
  <h:commandButton>
    <f:ajax render="@all" />
  </h:commandButton>
</h:form>

See also:

  • How to know if I am in a postback?
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda