2

独自のフォームを含む (Richfaces) ポップアップは、別のフォームを実行する必要がある保存ボタン ( contentForm) を提供し、検証の失敗が発生した場合は転送しません。

ただし、saveHandler.forward()常に呼び出されます...何かアイデアはありますか?

<a4j:commandButton 
    id="saveContentChanges" 
    value="Speichern" 
    action="#{cc.attrs.handler.save()}"
    type="submit"> 
    <a4j:ajax 
        execute=":contentForm" 
        render=":contentForm"
        oncomplete="if (#{!facesContext.validationFailed}) { saveHandler.forward() } else { #{rich:component('contentSaveHandlerPopup')}.hide() }"
        onerror="errorHandler.onError(event.description); #{rich:component('contentSaveHandlerPopup')}.hide();" />
</a4j:commandButton>

PS。このコードは複合コンポーネント内にあります。JavaScript コンソールでエラーは発生しません。

4

1 に答える 1

2

HTML では単一のフォームのみを送信できるため、この場合、a4j:commanButton存在するフォームのデータのみがクライアントからサーバーに送信されます。execute属性はサーバー側の処理にのみ影響し、データの送信方法は変更しません。したがって、別のフォームに追加するとexecute、実際にはサーバー側で処理されますが、送信された値がないため、検証するものが何もないことを意味します。

代替ソリューションは次のとおりです。

  1. (推奨) 送信して検証する必要がある同じフォームに、ボタンを含むポップアップを配置します。

  2. a4j:jsFunction を contentForm に配置し、ポップアップから呼び出すと、コードは次のようになります。

.

<h:form id="contentForm">
  .. other fields to be submitted ..
  <a4j:jsFunction name="executeContentFormAction" execute="@form" render="@form"
        action="#{...}"
        oncomplete="if ..."/>
</h:form>

...

<a4j:commandButton 
    id="saveContentChanges" 
    value="Speichern"
    onclick="executeContentFormAction(); return false;">
于 2013-08-21T16:15:17.843 に答える