PWC6228:模板文本正文中不允许 #{...} [英] PWC6228: #{...} not allowed in a template text body

查看:18
本文介绍了PWC6228:模板文本正文中不允许 #{...}的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 JS 脚本,它在提交按钮操作成功触发时调用:

I have a JS script which is called when a submit button action is fired successfully:

<h:panelGroup rendered="#{user$webreports$webfilteroverview.submitted}">
    <f:verbatim>
    <script  type="text/javascript">alert('Done!');</script>
    </f:verbatim>
</h:panelGroup>

上面的代码完美无缺.我想要做的是从资源包中获取警报框文本:

the above code works perfect. What I want to do is to get the alert box text from resource bundle:

<script  type="text/javascript">alert('#{msg.report_alert_text}');</script>

但我收到错误:

PWC6228:模板文本正文中不允许使用 #{...}.

PWC6228: #{...} not allowed in a template text body.

我是这样做的:

<h:commandbutton onClick="alert('#{msg.report_alert_text}');"/> 

它运行良好.我不明白为什么上面的代码不起作用.是否有可能做到这一点?如果是,上面的代码有什么问题?提前致谢.

and it was working fine. I don't understand why the above code doesn't work. Is it possible to do this? If yes, what is wrong with the above code? Thanks in advance.

推荐答案

PWC6228:模板文本正文中不允许使用 #{...}.

PWC6228: #{...} not allowed in a template text body.

您显然在使用遗留的 JSP(X) 而不是它的后继 Facelets.JSP(X) 不支持模板文本中的延迟 EL #{}.它仅支持模板文本中的标准 EL ${}(模板文本表示在标签/JSF 组件之外):

You're apparently using the legacy JSP(X) instead of its successor Facelets. Deferred EL #{} in template text is not supported by JSP(X). It only supports standard EL ${} in template text (template text means outside tags / JSF components):

<script type="text/javascript">alert('${msg.report_alert_text}');</script>

如果这不起作用,因为 ${msg} 没有准备好(#{} 将自动创建它,如果它当时还不存在视图),那么你需要 代替:

If that doesn't work because ${msg} is not been prepared (the #{} will namely autocreate it if it does not exist yet at that point of the view), then you need <h:outputText> instead:

<script type="text/javascript">alert('<h:outputText value="#{msg.report_alert_text}" />');</script>

您只需要删除 <f:verbatim> 标记即可让 JSF 组件在那里运行. 是 JSF 1.0/1.1 的遗留,自 JSF 1.2 起不再需要,自 JSF 2.1 起已弃用.

You'll only need to remove that <f:verbatim> tag in order to get JSF components to run there. The <f:verbatim> is a leftover from JSF 1.0/1.1 and not necessary anymore since JSF 1.2 and deprecated since JSF 2.1.

这个问题与 JavaScript 无关.错误来自网络服务器,而不是来自网络浏览器.

This problem has nothing to do with JavaScript. You got the error from the webserver, not from the webbrowser.

这篇关于PWC6228:模板文本正文中不允许 #{...}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆