そこで、ダイアログを開くボタンをクリックします。このダイアログ内で、フォームに情報を入力し、送信して保存したいと思います。一部のinputTextは、送信するために必要です。したがって、required = "true"属性を使用します。送信は停止しますが、すべての赤いアウトラインでフィールドが更新されるわけではありません。ここで、キャンセルを押してダイアログを再度開くと、検証に失敗したフィールドが赤いアウトラインで表示されます。
フォームを送信しようとするたびにダイアログを手動で更新することで、これを解決できると思いました。これにより、ダイアログを開いたまま更新して検証の失敗を表示するのではなく、ダイアログを閉じるだけです。
これはダイアログです。保存ボタンを押すと、フォームを送信します。
<h:form>
<p:dialog header="#{headerValue}" widgetVar="#{uniqueId}_editDialog"
modal="false" showEffect="fade" styleClass="dialogGrid"
dynamic="true" draggable="true" resizable="false">
<p:outputPanel style="text-align:center;" layout="block">
<p:messages autoUpdate="true"/>
<ui:insert name="editContent">
Edit Content Here. Use 'selectedModel.whatever'
</ui:insert>
<p:panelGrid columns="3" styleClass="buttonGrid">
<ui:insert name="saveButton">
<p:commandButton iconPos="left" value="#{msg.save}"
rendered="#{'VIEW' != selectedModel.viewState}"
process="@widgetVar(#{uniqueId}_editDialog)"
action="#{adapterInjector.add(modelList, selectedModel)}"
update="@widgetVar(#{uniqueId}_itemsDataList) @widgetVar(#{uniqueId}_addButton) @widgetVar(#{uniqueId}_editDialog)"
oncomplete="if(!args.validationFailed) PF('#{uniqueId}_editDialog').hide()"
partialSubmit="true" validateClient="true">
</p:commandButton>
</ui:insert>
<p:commandButton iconPos="right" value="#{msg.cancel}"
process="@this" oncomplete="PF('#{uniqueId}_editDialog').hide()"
resetValues="true" partialSubmit="true">
</p:commandButton>
</p:panelGrid>
</p:outputPanel>
</p:dialog>
</h:form>
これは、必要な属性を持つ挿入されたコンポーネントです
<p:selectOneMenu id="licenseCert"
value="#{selectedModel.selectedLicenseCert}" filter="true"
required="true">
<f:selectItem itemLabel="#{msg.selectOne}" itemValue=""
noSelectionOption="true" />
<f:selectItems value="#{licCert.allLicenseCertMap.entrySet()}"
var="entry" itemValue="#{entry.key}" itemLabel="#{entry.value}" />
</p:selectOneMenu>
</p:column>
これで問題が解決したことがわかりました。
ベストプラクティスについては、次のことを行う必要があります。
<h:form>
ダイアログ内を移動する<h:form>
保存ボタンで移動を処理します。この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加