Search code examples
bootstrap-modalgwtbootstrap3

Create Modal in gwtBootstrap3


My goal is create a modal with a few input fields and simple functionality on submit button press. I wanna use this gwtbootstrap3 modal : http://gwtbootstrap3.github.io/gwtbootstrap3-demo/snapshot/#modals . Is there any example how to create simple modal, with UiBinder, which would pop up on button click ?


Solution

  • Here is my solution, how to create Modal with UiBinder, in case there will be starters looking for easy answer:

    Modal.ui.xml :

    <b:Modal closable="true" dataKeyboard="true" ui:field="myModal">
        <b:ModalHeader>
            ..
        </b:ModalHeader>
        <b:ModalBody>
            ...
        </b:ModalBody>
    </b:Modal>
    

    Modal.java

    import org.gwtbootstrap3.client.ui.Modal;
    
    
    public class MyModal{
    
        @UiField
        Modal myModal;
    
        interface ModalViewUiBinder extends UiBinder<Widget,MyModal> {
        }
    
        private static ModalViewUiBinder uiBinder = GWT
                .create(ModalViewUiBinder.class);
    
        public MyModal() {
            uiBinder.createAndBindUi(MyModal.this);
        }
    
        public void show() {
            myModal.show();
        }
    }
    

    and on button click :

    MyModal modal = new MyModal();
    modal.show();