I am currently working on implementing a JSF table with a delete button. Below is the JavaScript code that triggers the dialog box:
function showDialog(a){
$("<div />", {
text: a
}).dialog({
width: 600,
buttons: {
"Ok": function() {
$("#myHiddenButtonID").click();
$(this).dialog("close");
},
"Cancel": function(event) {
$(this).dialog("close");
event.preventDefault();
}
}
});
}
To delete rows once confirmed in the dialog, I utilize a second hidden button:
<!-- hidden button -->
<h:commandButton id="myHiddenButtonID" value="DeleteHiddenButton" action="#{bean.deleteSelectedIDs}" style="display:none">
<f:ajax render="@form" execute="@form"></f:ajax>
</h:commandButton>
<!-- the button -->
<h:commandButton value="Delete">
<f:ajax execute="@form" onevent="showDialog('demo test')"></f:ajax>
</h:commandButton>
Despite setting up the confirmation dialog upon clicking the delete button, when I select YES, nothing seems to happen. It appears that the issue may lie with the hidden button ID, but my attempts to rectify it have been unsuccessful. The managed bean method does not get invoked.