我正在调试一个外国 JSF 应用程序。
问题是,我提交了一个表单,但值没有被结转。
使用阶段监听器我可以看到,生命周期没有完全运行,所以说它跳过阶段 2 -5:在恢复 View 阶段之后,直接调用渲染响应阶段。我想念应用值、验证、更新模型操作等。
所以,这可能是一个先有鸡还是先有蛋的问题:
1. 负责的阶段没有被调用,所以新的表单输入不能结转。
2.系统不识别任何新的输入,因此在恢复 View 后直接渲染。
我检查了没有调用 responseComplete() 或 renderResponse()。
我被卡住了。任何想法来验证这两个假设之一?或者一般如何调试?有人遇到过类似的问题吗?
更新
我怀疑 JSF 不知道回发请求并像初始 View 一样处理它。那可以解释,我只通过了第 1 阶段和第 6 阶段。
我如何检查 JSF 是否将其识别为非面孔请求?
如何检查当前 facesContext
中是否有合适的 treeID .
最佳答案
我引用了我发布的答案 before :
Whenever an
UICommand
component fails to invoke the associated action, verify the following:
UICommand
components must be placed inside anUIForm
component (e.g.h:form
).- You cannot nest multiple
UIForm
components in each other (watch out with include files!).- No validation/conversion error should have been occurred (use
h:messages
to get them all).- If
UICommand
components are placed inside anUIData
component, ensure that exactly the sameDataModel
(the object behind theUIData
'svalue
attribute) is preserved.- The
rendered
anddisabled
attributes of the component and all of the parent components should not evaluate tofalse
during apply request values phase.- Be sure that no
PhaseListener
or anyEventListener
in the request-response chain has changed the JSF lifecycle to skip the invoke action phase.- Be sure that no
Filter
orServlet
in the same request-response chain has blocked the request fo theFacesServlet
somehow.
因为在您的特定情况下,第 2-5 阶段被跳过,并且您确定(?)
FacesContext#renderResponse()
没有被调用,原因 3、6 和 7 可以从列表中删除。根据您调试 JSF 阶段的方式,原因 4 和 5 也可能被划伤。调查其他原因。我对事业 2 的评价。检查您是否没有看到 <form><form></form></form>
在生成的 HTML 源代码中并在 JSF 源代码中回溯它。
关于JSF 跳过阶段 - 如何调试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2712691/