how to use Bootstrap DateTimeRangePicker Add-on

Hello dear vaadin forum users!
I’m new in vaadin framework, but want to learn more. So i tried to reproduce my previous web interface writen in spring boot MVC in vaadin. So i faced next issue. Vaadin doesn’t have much functionality in date picker. In my case I need date-time range picker and in old project I used this component: https://www.daterangepicker.com/. I also found something similar for vaadin here https://vaadin.com/directory/component/bootstrap-datetimerangepicker-add-on/overview. But now I have no idea how to use it, I tried to read some docs in github, look at examples, but it looks very complicated for me. Can someone explain to me, how can i use this add-on as vaadin component in my project? I’m not able to add this as vaadin component because DateTimeRangeField class is not part of it. I’m trying to use this in class, that extends Dialog.

public class AddTourForm extends Dialog {
    private static final String DATE_PATTERN = "dd-MM-yyyy";
    private static final Format DATE_FORMATTER = new SimpleDateFormat(AddTourForm.DATE_PATTERN);

    private TextField title = new TextField();
    private TextField description = new TextField();
    private DateTimeRangeField date = new DateTimeRangeField(DATE_FORMATTER, true, true);

    public AddTourForm() {
        setupDatePicker();
        add(title,description);
    }

    private void setupDatePicker(){
        date.autoApply(true);
        date.timePicker(true);
        date.timePicker24Hour(true);
        date.timePickerIncrement(5);

    }
}

DemoUI from github also didn’t helps. Even if I just try to create an object (new DateTimeRangeField) it throws null pointer exception.
Note: instead of maven I’m using gradle, maybe because of this I cannot try DemoUI described in github. Anyway please help me to find out solution.
Thanks!

Hi, the Bootstrap DateTimeRangePicker add-on is to Vaadin 8, then you can no integrate, assuming that you use Vaadin 14
See https://vaadin.com/docs/v14/flow/migration/1-migrating-v8-v10.html
Then you have two options search a DateTimeRangePicker polymer 3 web component or ES6 module to [integrate]
(https://vaadin.com/docs/v14/flow/web-components/integrating-a-web-component.html)
or [import the js]
(https://vaadin.com/docs/v14/flow/importing-dependencies/tutorial-importing.html) and use [client-server-rpcs]
(https://vaadin.com/docs/v14/flow/element-api/client-server-rpc.html)

Johny Ortega:
Hi, the Bootstrap DateTimeRangePicker add-on is to Vaadin 8, then you can no integrate, assuming that you use Vaadin 14
See https://vaadin.com/docs/v14/flow/migration/1-migrating-v8-v10.html
Then you have two options search a DateTimeRangePicker polymer 3 web component or ES6 module to [integrate]
(https://vaadin.com/docs/v14/flow/web-components/integrating-a-web-component.html)
or [import the js]
(https://vaadin.com/docs/v14/flow/importing-dependencies/tutorial-importing.html) and use [client-server-rpcs]
(https://vaadin.com/docs/v14/flow/element-api/client-server-rpc.html)

Hi Johny Ortega! Thank u very much for your reply. But actually I’m not familiar with vaadin, web components and ES6, I don’t even know what is it and how to use it. There is no way in vaadin to use in code components like this (http://www.daterangepicker.com/) ? What if I didn’t found any components as you described (polymer and es6 modules), what to do?

Hi,

The easiest way to do that in Vaadin is to create a CustomField with 2 DatePickers (From - To).

The result is different but, it could be a first step:
https://vaadin.com/components/vaadin-custom-field/java-examples
There is already an addon here: https://vaadin.com/directory/component/daterange-picker

I’m not 100% sure that this add-on is working for Vaadin 14, but I think it should.

If you really want to use this component (it requires 2 big dependencies: jquery and momentjs), you can integrate it in Vaadin.
I recommend you to start with the integration of jquery: https://vaadin.com/learn/tutorials/integrate-jquery-into-vaadin-flow