Not able to get return value back from confirmation dialog

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Not able to get return value back from confirmation dialog

Prafulla Patil
Hello,

I want to call Fun1() if user clicks on OK button in the confirmation message or call Fun2() if user clicks on Cancel button.
Right now what happening is if user clicks on Cancel nothing happens and if user clicks on OK button then onSubmit() is called.

Problem is not able to get return value from Confirm Dialog in wicket class, code is as follows, please suggest.

 Button saveButton = new Button("save") {  
                 @Override  
                 public void onSubmit() {    }  }  
   
 saveButton.add(new SimpleAttributeModifier("onclick", "if(!confirm('"+sUpdateMessage+"')) return false;"));  


Reply | Threaded
Open this post in threaded view
|

Re: Not able to get return value back from confirmation dialog

Prafulla Patil
Hello,

as there was no reply from anyone to my post and I was trying to resolve this issue whole day and finally Succeeded and resolution is as follows,

Hidden Field added into the form to populate Confirm functions return value and then it is used to call fun1 or fun2.
view plaincopy to clipboardprint?

   1.      
   2. <input type="hidden" wicket:id="updateFlowInstance" > 
   3.    

<input type="hidden" wicket:id="updateFlowInstance" >

java code is as follows .
view plaincopy to clipboardprint?

   1. final HiddenField<String> updateFlowInstanceHiddenField = new HiddenField<String>("updateFlowInstance");  
   2.  
   3. addEditAttributeForm.add(updateFlowInstanceHiddenField);  
   4.  
   5. saveButton.add(new SimpleAttributeModifier("onclick",  "document.getElementById('updateFlowInstance').value=confirm('Are you sure ?');"));  

final HiddenField<String> updateFlowInstanceHiddenField = new HiddenField<String>("updateFlowInstance"); addEditAttributeForm.add(updateFlowInstanceHiddenField); saveButton.add(new SimpleAttributeModifier("onclick", "document.getElementById('updateFlowInstance').value=confirm('Are you sure ?');"));

Problem is resolved now, we have return value in the hidden field now.


Prafulla Patil wrote
Hello,

I want to call Fun1() if user clicks on OK button in the confirmation message or call Fun2() if user clicks on Cancel button.
Right now what happening is if user clicks on Cancel nothing happens and if user clicks on OK button then onSubmit() is called.

Problem is not able to get return value from Confirm Dialog in wicket class, code is as follows, please suggest.

 Button saveButton = new Button("save") {  
                 @Override  
                 public void onSubmit() {    }  }  
   
 saveButton.add(new SimpleAttributeModifier("onclick", "if(!confirm('"+sUpdateMessage+"')) return false;"));