2

I have a page with delete button. I would like to show a custom warning dialog when delete button is clicked. I cannot use onClick confirmDelete() js method as I need to customize the warning message based on some business logic.

In the controller I thought of writing an action for delete, but not sure how to show javascript warning dialog from there.

1

You cannot show a JS dialog from within your controller, the best you can do is show a dialog on click of the button (you can use jQueryUI for customization). When clicked on true, you can call an actionFunction to delete the record, if clicked on false, just dismiss the dialog.

This will save any additional ajax calls to the controller

0

i think you have to display confirmation window before any action performed on button click.

<apex:commandButton id="delete" value="Delete" action="{!DeleteData}" onclick="if(!confirm('Are you sure?')){return};"/>

i thing this might be usefull for you if im wrong then plz correct me.

  • Basically I would like to do validation and based on the validation result show a warning dialog, and if user clicks OK button I need to execute delete action. – user20243 May 6 '15 at 10:52
  • On what condition of validation do you like to show warning dialog? Suppose validation is false then what? and if true then what? – DKSalesforce Lerner May 6 '15 at 11:00
  • Basically I would like to do validation and based on the validation result show a warning dialog, and if user clicks OK button I need to execute delete action. Some thing like <br/> public void deleteRecord() { // Validate Boolean validateResult = validateDelete(this.id); // show warning dialog based on validateResult executeDelete(this.id); }<br/> I would like to know if there is way to save intermediate result, show warning dialog based on the result and then call another function in controller – user20243 May 6 '15 at 11:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.