El siguiente fragmento de código genera un error de sintaxis de javascript cuando 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
El problema es la const label = '*' . ¿Cómo lidiar con eso en este caso?
Mojarra 2.3.14
Puede hacer que h:outputScript condicional, en función de facesContext.postback . Si usa rendered="#{not facesContext.postback}" solo se procesará en la solicitud inicial y no con las solicitudes de Ajax:
<h:outputScript rendered="#{not facesContext.postback}"> 'use strict'; const label = '*'; </h:outputScript> <h:form> <h:commandButton> <f:ajax render="@all" /> </h:commandButton> </h:form>Ver también: