Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package org.cdlflex.ui.markup.html.form;
 
 import java.util.Date;
 
A DateTextField extension that uses bootstrap-datepicker as frontend and can handle a specified date pattern that conforms to SimpleDatePattern. The components properties map to the ones of bootstrap-datepicker.
 
 public class DateTimePicker extends DateTextField {
 
     private static final long serialVersionUID = 1L;
 
     private boolean pickDate = true;
     private boolean pickTime = true;
     private boolean sideBySide;
     private String language = "en";
 
     public DateTimePicker(String id) {
         super(id);
     }
 
     public DateTimePicker(String idIModel<Datemodel) {
         super(idmodel);
     }
 
     public DateTimePicker(String idString datePattern) {
         super(iddatePattern);
     }
 
     public DateTimePicker(String idIModel<DatemodelString datePattern) {
         super(idmodeldatePattern);
     }
 
     public boolean isPickDate() {
         return ;
     }

    
Enables/Disables the date picker.

Parameters:
pickDateFlag true if date picker should be enabled
Returns:
this for chaining
 
     public DateTimePicker setPickDate(boolean pickDateFlag) {
         this. = pickDateFlag;
         return this;
     }
 
     public boolean isPickTime() {
         return ;
     }

    
Enables/Disables the time picker.

Parameters:
pickTimeFlag true if time picker should be enabled
Returns:
this for chaining
 
     public DateTimePicker setPickTime(boolean pickTimeFlag) {
         this. = pickTimeFlag;
         return this;
     }
 
     public boolean isSideBySide() {
         return ;
     }

    
Show the date and time picker side by side.

Parameters:
sideBySideFlag flag
Returns:
this for chaining
 
     public DateTimePicker setSideBySide(boolean sideBySideFlag) {
        this. = sideBySideFlag;
        return this;
    }
    public String getLanguage() {
        return ;
    }

    
Sets language locale.

Parameters:
languageLocale the language string, e.g. 'en'
Returns:
this for chaining
    public DateTimePicker setLanguage(String languageLocale) {
        this. = languageLocale;
        return this;
    }

    
Returns the result of org.apache.wicket.extensions.markup.html.form.DateTextField.getTextFormat() (which is a java DateFormat pattern) as a text format that is understood by moment.js.

Returns:
a moment.js date format string
    public String getMomentJsDateFormat() {
        if (getTextFormat() == null) {
            return null;
        } else {
            return new MomentJsDateFormatConverter().convert(getTextFormat());
        }
    }
    @Override
    protected void onInitialize() {
        super.onInitialize();
        getPage().add(
                new FrontendDependencyBehavior(BootstrapDatePickerJsResourceReference.get(),
                        BootstrapDatePickerCssResourceReference.get()));
        add(newWidgetBehavior());
    }

    
Creates the WidgetBehavior that provides the frontend behavior for this component.

Returns:
a new WidgetBehavior instance
    protected WidgetBehavior newWidgetBehavior() {
        PropertyBindingOptions options =
            new PropertyBindingOptions(this"pickDate""pickTime""language""sideBySide");
        options.add("format""momentJsDateFormat");
        return new WidgetBehavior("datetimepicker"options);
    }
New to GrepCode? Check out our FAQ X