JSF 跳过阶段 - 如何调试?

发布于 2024-08-30 10:09:37 字数 504 浏览 5 评论 0原文

我正在调试一个外部 JSF 应用程序。 问题是,我提交了表单,但值没有保留。

通过阶段侦听器,我可以看到生命周期并未完全运行,也就是说它跳过了阶段 2 -5:在恢复视图阶段之后,直接调用渲染响应阶段。我怀念应用值、验证、更新模型操作等。

所以,这可能是一个先有鸡还是先有蛋的问题: 1. 不调用负责的阶段,因此无法继承新的表单输入。 2. 系统无法识别任何新输入,因此恢复视图后直接渲染。

我检查没有调用responseComplete()或renderResponse()。

我不知何故被困住了。有什么想法可以验证这两个假设之一吗?或者一般如何调试?有人遇到过类似的问题吗?


更新

我怀疑 JSF 不知道回发请求,并像处理初始视图一样处理此请求。这就解释了,我只通过了第一阶段和第二阶段。 6.

如何检查 JSF 是否将其识别为非面孔请求?
如何检查当前 facesContext 中是否存在适当的treeID

I'm debugging a foreign JSF application.
The problem is, that I submit a form, but the values aren't carried over.

With a phase listener I can see, that the life cycle doesn't run completely through, so to say it skips phase 2 -5: After the restore view phase, the render response phase is directly called. I miss the apply values, validation, update model actions and so on.

So, this could be a chicken-and-egg problem:
1. The responsible phases aren't called, so the new form input can't be carried over.
2. The system doesn't recognize any new input and therefore directly renders after restoring the view.

I checked that there is no call of responseComplete() oder renderResponse().

I'm stuck somehow. Any idea to validate one of the two hypothesis? Or how to debug that in general? Did anybody have a similar problem?


Update

I have a suspicion, that JSF isn't aware of the postback request and handles this like an initial view. That would explain, that I only pass phase 1 & 6.

How can I check, if JSF recognizes this as a non-faces-request?
How can I check, if there is the appropriate treeID in the current facesContext.

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

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

发布评论

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

评论(2

夏日浅笑〃 2024-09-06 10:09:37

我引用我之前发布的答案:

每当 UICommand 组件
无法调用关联的操作,
验证以下内容:

  1. UICommand 组件必须放置在 UIForm 组件内
    (例如h:form)。
  2. 您不能相互嵌套多个 UIForm 组件
    (注意包含文件!)。
  3. 不应该发生验证/转换错误(使用
    h:messages 获取所有内容)。
  4. 如果 UICommand 组件放置在 UIData 组件内,
    确保完全相同
    DataModel(背后的对象
    UIDatavalue 属性)是
    保留。
  5. 组件的 rendereddisabled 属性以及所有
    父组件不应该
    应用期间评估为 false
    请求值阶段。
  6. 确保没有 PhaseListener 或任何 EventListener
    请求-响应链改变了
    JSF 生命周期跳过调用
    行动阶段。
  7. 确保同一请求响应中没有 FilterServlet
    链已阻止该请求
    FacesServlet 不知何故。

由于在您的特定情况下,阶段 2-5 被跳过并且您确定(?)没有调用 FacesContext#renderResponse(),因此原因 3、6 和 7 可以是从列表中删除。原因 4 和 5 也可能被排除,具体取决于您调试 JSF 阶段的方式。调查其他原因。我对原因 2 的看法。检查您是否在生成的 HTML 源代码中没有看到

并在 JSF 源代码中回溯。

I'm quoting from an answer I've posted before:

Whenever an UICommand component
fails to invoke the associated action,
verify the following:

  1. UICommand components must be placed inside an UIForm component
    (e.g. h:form).
  2. You cannot nest multiple UIForm components in each other
    (watch out with include files!).
  3. No validation/conversion error should have been occurred (use
    h:messages to get them all).
  4. If UICommand components are placed inside an UIData component,
    ensure that exactly the same
    DataModel (the object behind the
    UIData's value attribute) is
    preserved.
  5. The rendered and disabled attributes of the component and all of
    the parent components should not
    evaluate to false during apply
    request values phase.
  6. Be sure that no PhaseListener or any EventListener in the
    request-response chain has changed the
    JSF lifecycle to skip the invoke
    action phase.
  7. Be sure that no Filter or Servlet in the same request-response
    chain has blocked the request fo the
    FacesServlet somehow.

Since in your particular case the phases 2-5 are been skipped and that you're certain(?) that FacesContext#renderResponse() isn't been called, the causes 3, 6 and 7 can be scratched from the list. The causes 4 and 5 can likely also be scratched, depending on the way how you debugged the JSF phases. Investigate the other causes. My cents on cause 2. Check if you don't see <form><form></form></form> in generated HTML source and backtrack this in JSF source.

栀子花开つ 2024-09-06 10:09:37

找到解决方案了!
很抱歉,但我猜这是非常特定于应用程序的:JSF 的自定义 StateManager 无法与 JSF 1.2 一起使用。这导致了这个奇怪的错误。
修复了 StateManager,一切正常。这很痛苦并且花费了很多时间:-(

无论如何感谢您的帮助:-)

Found the solution!
I'm sorry but it was very application specific I guess: The custom StateManager for JSF wasn't usable with JSF 1.2. That caused this strange error.
Got the StateManager fixed and everything worked fine. That's bitter and cost a lot of time :-(

Thanks for your help anyway :-)

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