Skip to content

BootstrapDatepicker

André Camilo edited this page Jan 5, 2015 · 2 revisions

BootstrapDatepicker

This component creates a date picker for an input field (it needs to be a DateTextField). It supports internationalization out of the box, the locale included on the page is the Wicket session locale.

The javascript library we used for this component is: https://github.com/eternicode/bootstrap-datepicker

Example

In this example we create a datepicker initialized with today's date.

The html code:

    <div class="date" data-date-autoclose="true" 
            data-date-clear-btn="true" wicket:id="inputDate">
        <span class="add-on"></span>
        <input wicket:id="inputTextField" type="text"/>
    </div>

The java code:

    BootstrapDatepicker input = new BootstrapDatepicker("inputDate");
    input.add(new DateTextField("inputTextField", Model.of(DateTime.now())));
    add(input)

Read the date in the model:

    input.getModel().getObject()

Customization

  • Add a clear button
    data-date-clear-btn="true"
  • See the bootstrap datepicker documentation for other options:

http://bootstrap-datepicker.readthedocs.org/en/release/options.html

Clone this wiki locally