JSF el 未解析

发布于 2024-12-27 08:19:30 字数 282 浏览 2 评论 0原文

我在 JSF 页面中有以下行:

<h:commandLink action="#{myBean.test}" value="Wizard Step"></h:commandLink>

我希望加载页面时,对应于 myBean 的 Bean 将被实例化(并且我将能够在 eclipse 调试器中看到这一点)。

JSF 的其余部分工作正常,但该 bean 无法解析(没有任何错误)。

如何从 el 无法解析 bean 中获取错误?

I have the following line in a JSF page:

<h:commandLink action="#{myBean.test}" value="Wizard Step"></h:commandLink>

I expect that when the page is loaded, the Bean corresponding to myBean will be instantiated (and I'll be able to see this in the eclipse debugger).

The rest of the JSF is working correctly, but this bean is not resolving (without any error).

How do I get the errors from the el failing to resolve the bean?

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

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

发布评论

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

评论(1

错爱 2025-01-03 08:19:30

如果有 EL 错误,你肯定会得到 javax.el

在您的情况下,托管 bean 不是根据初始请求构建的。这只能意味着该托管 bean 没有在视图的其他地方被引用。 action 属性中的 EL 仅在提交表单时评估。因此,只有在调用操作时才会构造 bean。作为测试,只需将 #{myBean} 放置在视图中的某个位置即可。您将看到它是根据初始请求构建的。

您的真正问题是命令按钮操作根本不被调用,因此根本不评估其操作属性中的 EL。该问题无法在 EL 方面进行调试或确定。按钮操作未被调用的可能原因有很多。您可以在这里找到它们: commandButton/commandLink/ajax action/listener 方法未调用或输入值未更新。初学者中最常见的原因是按钮位于重复组件(如 )内,其值未正确保存并在表单提交请求期间返回完全不同的值,或者组件或其组件之一具有 rendered 属性,该属性未正确保留且默认为 false

If there are EL errors, you will surely get an exception of javax.el package:

  • ELException: Represents any of the exception conditions that can arise during expression evaluation.
  • MethodNotFoundException: Thrown when a method could not be found while evaluating a MethodExpression.
  • PropertyNotFoundException: Thrown when a property could not be found while evaluating a ValueExpression or MethodExpression.
  • PropertyNotWritableException: Thrown when a property could not be written to while setting the value on a ValueExpression.

In your case, the managed bean is not constructed on initial request. This can only mean that the managed bean is not referenced elsewhere in the view. The EL in action attribute is only evaluated when the form is submitted. So the bean will only be constructed when the action is invoked. As a test, just put #{myBean} somewhere in the view. You'll see that it get constructed on initial request.

Your real problem is that command button action is simply not invoked, so the EL in its action attribute is simply not evaluated at all. The problem cannot be debugged nor nailed down in the EL side. There are a lot of possible causes for the button action not being invoked. You can find them all here: commandButton/commandLink/ajax action/listener method not invoked or input value not updated. The most common cause among starters is that the button is inside an repeating component like <h:dataTable> whose value is not properly preserved and returns a completely different value during the form submit request, or that the component or one of its components has a rendered attribute which is not properly preserved and defaults to false.

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