ConfirmDialog in CustomComponent ?

Hello

I did download ConfirmDialog add-on. Now, I’m trying create a confirmdialong in my customcomponent, but I guess that doesn’t work with this ui.



public class Customer extends CustomComponent implements Button.ClickListener{
      private Button btnSave;
      private VerticalLayout vLayout;
      
      public Customer(){
            vLayout = new VerticalLayout();
            setCompositionRoot(vLayout);
            btnSave = new Button("Save");
            btnSave.addClickListener(this);
            vLayout.addComponent(btnSave);
      }

      @Override public void buttonClick(ClickEvent event) {
             if(event.getButton() == btnSave){
                     save();
             }
       }
       
       /** save informations if ConfirmDialog return true */
       private void save(){
              ConfirmDialog.show(this, "Please Confirm:",
                                                       "Are you really sure?",
                                                       "I am", "Not quite",
                                                       new ConfirmDialog.Listener() {
                                                                 public void onClose(ConfirmDialog dialog) {
                                                                            if (dialog.isConfirmed()) {
                                                                                     System.out.println(dialog.isConfirmed());
                                                                            } else {
                                                                                     System.out.println(dialog.isConfirmed());
                                                                            }
                                                                 }
                                                        });
         }
}


When I create ConfirmDialog and pass my CustomComponent as Ui(this) does not accept. I tryed pass null, but does not work also.

Any idea ?

Hi Fernando,

You can pass getUI() as parameter.

ConfirmDialog.show(getUI(), “Please Confirm:”, …);

Felype Santiago Ferreira