如何在Jsf中同步a4j:jsFunction和actionListener
我有以下执行代码,但它给出了一些与问题相关的ajax请求 点击按钮调用actionListener如何在Jsf中同步a4j:jsFunction和actionListener,jsf,jsf-2,ajax4jsf,Jsf,Jsf 2,Ajax4jsf,我有以下执行代码,但它给出了一些与问题相关的ajax请求 点击按钮调用actionListener <a4j:commandButton value="Submit" alt="OligoWalk" styleClass="common_button" onclick="createNewLog();showProgressLayer();" oncomplete="parent.document.getElementById('resultFrm').src ='#{MyResearch
<a4j:commandButton value="Submit" alt="OligoWalk" styleClass="common_button" onclick="createNewLog();showProgressLayer();" oncomplete="parent.document.getElementById('resultFrm').src ='#{MyResearchView.resultToShow}';parent.reRenderLogSection();" actionListener="#{MyResearchView.executeTool}"> <f:attribute name="toolClass" value="com.sequerome.service.impl.tools.Oligowalk" />
<f:attribute name="toolId" value="#{ToolCustomeFormView.toolId}" /> <f:attribute name="toolName" value="#{ToolCustomeFormView.toolName}" /> <f:attribute name="inputParamFile" value="#{ToolCustomeFormView.inputParamFile}" />
<f:attribute name="paramMap" value="#{ToolCustomeFormView.toolParamBean.paramMap}" />
</a4j:commandButton>
A4j:jsFunction
<a4j:jsFunction name="createNewLog"
actionListener="#{MyResearchView.createNewLogEntry}"
oncomplete="parent.reRenderLogSection();executeTool();">
<f:attribute name="toolId" value="#{ToolCustomeFormView.toolId}" />
<f:attribute name="toolName" value="#{ToolCustomeFormView.toolName}"/></a4j:jsFunction>
<a4j:commandButton value="Submit" alt="OligoWalk" styleClass="common_button" onclick="createNewLog();showProgressLayer();" oncomplete="parent.document.getElementById('resultFrm').src ='#{MyResearchView.resultToShow}';parent.reRenderLogSection();" actionListener="#{MyResearchView.executeTool}"> <f:attribute name="toolClass" value="com.sequerome.service.impl.tools.Oligowalk" />
<f:attribute name="toolId" value="#{ToolCustomeFormView.toolId}" /> <f:attribute name="toolName" value="#{ToolCustomeFormView.toolName}" /> <f:attribute name="inputParamFile" value="#{ToolCustomeFormView.inputParamFile}" />
<f:attribute name="paramMap" value="#{ToolCustomeFormView.toolParamBean.paramMap}" />
</a4j:commandButton>
<a4j:jsFunction name="createNewLog"
actionListener="#{MyResearchView.createNewLogEntry}"
oncomplete="parent.reRenderLogSection();executeTool();">
<f:attribute name="toolId" value="#{ToolCustomeFormView.toolId}" />
<f:attribute name="toolName" value="#{ToolCustomeFormView.toolName}"/></a4j:jsFunction>
不确定您的目标是什么。一些代码会有所帮助。a4j:jsf函数有一个名为oncomplete的javascript事件。我想一种方法是在收到此事件时调用其他js函数…症状可能是a4j:函数是异步函数的结果。我相信幕后的情况是:
- createNewLog();
- 调用a4j:function
- a4j:函数发送请求
- a4j:函数返回(请求仍在发生)
- showProgressLayer();
- 调用a4j:function
- a4j:FUNCTION发送一个请求(createNewLog请求刚好完成了一半)
- a4j:函数返回(请求仍在发生)
- 已激发actionListener请求
- 请求在服务器上执行,可能在createNewLog和showProgressLayer仍在运行时执行
解决方案是在客户端和服务器端添加。OP没有格式化代码,因此被吞并。我修正了代码格式。