JSF呈现的方法不会在第二次调用
我有下一个a4j:jsFunctionJSF呈现的方法不会在第二次调用,jsf,jsf-2,richfaces,Jsf,Jsf 2,Richfaces,我有下一个a4j:jsFunction <a4j:jsFunction name="renderOnBusinessErrorEvent" execute="@none" bypassUpdates="true" immediate="true" render="securityForm"> </a4j:jsFunction> 和JSF表单,其中包含一些对话框 <h:form id="securityForm">
<a4j:jsFunction name="renderOnBusinessErrorEvent" execute="@none" bypassUpdates="true" immediate="true"
render="securityForm">
</a4j:jsFunction>
和JSF表单,其中包含一些对话框
<h:form id="securityForm">
<h:panelGroup rendered="#{someCondition}">
......
</h:panelGroup>
</h:form>
......
在我的业务逻辑中,它必须执行两次。第一次一切都很好。调用呈现的方法,并且页面上显示预期的对话框。在第二次渲染时,未调用该方法,但模型已更改,我希望该对话框不会出现在页面上。我想这是richfaces的问题,我尝试使用f:ajax
<a4j:jsFunction name="renderOnBusinessErrorEvent" execute="@none" bypassUpdates="true" immediate="true">
<f:ajax event="begin" render=":securityForm"/>
</a4j:jsFunction>
但没有成功。第二次仍未调用呈现的方法。这是怎么一回事?一些JSF优化还是bug?解决办法是什么?
JSF版本2.1.19问题出在
over h:form,在第一次渲染后等于false(在服务器端)。
但是,此面板组不是渲染的一部分。所以,我的代码:
<h:panelGroup rendered="#{someOtherCondition}">
<h:form id="securityForm">
<h:panelGroup rendered="#{someCondition}">
......
</h:panelGroup>
</h:form>
</h:panelGroup>
<h:form>
<a4j:jsFunction name="renderOnBusinessErrorEvent" execute="@none" bypassUpdates="true" immediate="true"
render="securityForm">
</a4j:jsFunction>
</h:form>
......
在调用renderOnBusinessErrorEvent()之前,我正在将someOtherCondition的值从true更改为false,但我不会重新渲染此元素。实际上,在服务器端,这个元素已经丢失了。看起来它是JSF特性,但是它在什么地方被指定了吗?您没有说明如何以及何时调用该函数。您还应该检查网络活动,如果有两个请求,则该函数执行了两次。@Makhiel我只是通过类似renderOnBusinessErrorEvent()的javascript调用该函数;延迟约2秒。网络活动正常(200),但对同一请求的响应不同。@Makhiel如果我没有很清楚地描述问题的细节,以防万一我会解释。此函数执行了两次。我为调试添加了console.log。但第二次呼叫的响应与第一次呼叫不同。我不知道为什么。如果JSF的行为不正确,我希望不是这样,那么我将尝试在小项目中重现它,并在JSF bug tracker中创建新问题。答案有什么不同?如果要呈现不同的东西,它们必须是不同的。通过a4j:log,我找到了问题的根源。我已将此消息作为单独的答复发布。谢谢。正如您所看到的,JSF会发回一些HTML代码,因为表单的父级没有呈现,所以表单也没有呈现,所以没有发送任何代码。@Makhiel。但这并不明显。当页面上缺少元素时,JSF应该抛出FacesException。但我知道不是富人。这就是我使用f:ajax进行检查的原因