Vaadin 8 Sub Window by using an Addon messagebox


Code is as Follows



TextField name = new TextField("Name");
        TextField country = new TextField("country");
        TextField network = new TextField("Network");
        SubWindow subWindow = new SubWindow();
        subWindow.setCaption("Sub-window");
        VerticalLayout subcontent = new VerticalLayout();
        subWindow.setContent(subcontent);
     
        subWindow.setHeight("350px");
        subWindow.setWidth("500px");

        subcontent.addComponents(name, country, network);

        subWindow.center();


 grid.addItemClickListener(e -> {
            String putName = e.getItem().name.toString();
            name.setValue(putName);
            name.focus();
            String putCountry = e.getItem().country.toString();
            country.setValue(putCountry);
            String putNetwork = e.getItem().network.toString();
            network.setValue(putNetwork);
            if (subWindow.isAttached()) {
                UI.getCurrent().removeWindow(subWindow);
            }
            UI.getCurrent().addWindow(subWindow);
        });
    }



class SubWindow extends Window {

    private static final long serialVersionUID = 1L;

    @Override
    public void close() {
        MessageBox.createQuestion().withCaption("Do you want to Really close the Window")
                .withMessage("Pakku ne ?").withYesButton(() -> super.close())
                .withNoButton(() -> {})
                .open();
    }
}

Comments

  1. How can I then write Multiline codes in .WithYesButton() ? oder returning a function like, .WithYesButton(()-> return RemoveAll())

    RemoveAll() returns true or false

    Thanks

    ReplyDelete
  2. Hello @Reza Payambari this is just the addon I used for generting close warning notification

    You can make your custom methods in order to implement multiline codes.

    ReplyDelete

Post a Comment

Popular posts from this blog

State space search / blocks world problem by heuristic approach /TIC TAC TOE

Navigation in Vaadin.

Drag and drop items from one Grid to another