Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Jsf中同步a4j:jsFunction和actionListener_Jsf_Jsf 2_Ajax4jsf - Fatal编程技术网

如何在Jsf中同步a4j:jsFunction和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

我有以下执行代码,但它给出了一些与问题相关的ajax请求

点击按钮调用actionListener

<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>

  • createNewLog()函数必须首先完成
  • 在此之后,必须完成executeTool()函数
  • 当前,它以相同的方式调用,但createNewLog()函数的一半先执行,然后转到executeTool()函数。在这里,它需要一些代码来执行,然后再次转向createNewlog()函数。在此之后,执行createNewLog(),然后再次执行executeTool()

    <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没有格式化代码,因此被吞并。我修正了代码格式。