質問ダイアログ付きのJSFボタンのこの例を作成しました。
<!-- hidden button -->
<h:commandButton id="deleterow" value="HiddenDelete" action="#{AccountProfileTabGeneralController.saveData}" style="display:none" update="growl">
<f:ajax render="@form" execute="@form"></f:ajax>
</h:commandButton>
<!-- edit button -->
<h:button style="position:absolute; bottom:12px; right:12%;" rendered="#{AccountProfileTabGeneralController.editable}" styleClass="lbimage" value=" Save Account " onclick="editdialog(this, 'Do you want to save the changes?'); return false;" />
このJSを使用してダイアログを表示します。
function editdialog(button, a){
$("<div />", {
text: a
}).dialog({
width: 600,
buttons: {
"Ok": function() {
$("#form\\:deleterow").click();
$(this).dialog("close");
button.value = "Processing...";
button.disabled = true;
},
"Cancel": function(event) {
$(this).dialog("close");
event.preventDefault();
button.value = "Save Account";
button.disabled = false;
}
}
});
}
しかし、何らかの理由で[OK]ボタンをクリックすると、ボタンが無効になり、機能しなくなります。フォームのIDが正しくない可能性があります。私はこれを使います<h:form id="general">
どうすれば問題を解決できますか?また、異なるIDのフォームでコードを使用するにはどうすればよいですか?