0

送信時の簡単なフォームで、これに対して2つのリクエストが行われていることがわかります。

<h:form id="form1">
    <a4j:commandButton value="Send" id="cm1" onclick="sendData(193)"/>
    <a4j:jsFunction name="sendData">
      <a4j:param name="param1" assignTo="#{outageManagementAction.deleteEngineId}" />
    </a4j:jsFunction>
   </h:form>

JSFによって生成されたコードは次のとおりです...

<form id="form1" name="form1" method="post" action="/moutagev1/faces/pages/xOutageEdit.xhtml" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="form1" value="form1" />
<input id="form1:cm1" name="form1:cm1" onclick="jsf.util.chain(this,event,&quot;sendData(193)&quot;,&quot;RichFaces.ajax(\&quot;form1:cm1\&quot;,event,{\&quot;incId\&quot;:\&quot;1\&quot;} )&quot;);return false;" value="Send" type="submit" /><span id="form1:j_idt257" style="display: none;"><script type="text/javascript">sendData=function(param1){RichFaces.ajax("form1:j_idt257",null,{"parameters":{"param1":param1} ,"incId":"1"} )};</script></span><input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="8425501786648002013:2772799535475824519" autocomplete="off" />
</form>

なぜこれが起こっているのか...

4

1 に答える 1

0

さて、1 つのリクエストは標準的な投稿で<h:form>、2 つ目のリクエストはカスタム<a4j:jsFunction>であり、クリックが発生したときに送信と一緒にチェーンされます。

1 つの解決策は、次のようにボタンのタイプを変更して、標準の送信を抑制することです<a4j:commandButton type="button" />

もう 1 つの選択肢は、まったく使用<a4j:jsFunction>しないことです。代わりにこれを使用します。

<f:setPropertyActionListener target="#{outageManagementAction.deleteEngineId}" value="193" />
于 2013-08-31T14:34:42.443 に答える