I'm trying to implement JSF table with delete button. This is the JavaScript which displays the dialog:
function dialog(a){
$("<div />", {
text: a
}).dialog({
width: 600,
buttons: {
"Ok": function() {
$("#myHiddenButtonID").click();
$(this).dialog("close");
},
"Cancel": function(event) {
$(this).dialog("close");
event.preventDefault();
}
}
});
}
I use second hidden button to delete the rows when the user confirms from the dialog:
<!-- 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="dialog('demo test')"></f:ajax>
</h:commandButton>
When I click on the delete button the dialog appears to confirm the deletion of the table rows. Then I click YES nothing happens. I suppose that the hidden button id is the problem but when I try to fix it nothing happens. The managed bean method is not called.