JSF 2.3.14:(重新)呈现JavaScript代码块(常数)之后的语法错误

发布于 2025-01-30 09:45:12 字数 452 浏览 4 评论 0原文

当我按下h:commandbutton

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

syntaxerror:const Label label

问题是,问题是const label ='*'*'*'*'*'*。在这种情况下如何处理?

Mojarra 2.3.14

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦境 2025-02-06 09:45:12

您可以基于faceScontext.postback进行h:outputscript条件。如果您使用rendered =“#{不facescontext.postback}”它只会在初始请求中渲染,而不是在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>

另请参见:

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:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文