public class DateTimePickerOptionsCreator {
private ClientConfigBean _clientConfigBean;
public DateTimePickerOptionsCreator(ClientConfigBean clientConfigBean) {
_clientConfigBean = clientConfigBean;
}
public DateTimePickerOptions invoke() {
DateTimePickerOptions options = new DateTimePickerOptions();
ResourceReference icon = new PackageResourceReference(CatalogBasePage.class, "css/images/icon1.png");
Map<DefaultSettingTypeEnum, String> defaultSettings = _clientConfigBean.getDefaultSettings();
String dateFormat = defaultSettings.get(DefaultSettingTypeEnum.dateOnlyFormat);
String jqueryUIDate = new SimpleDateFormatToJQueryUIFormatConverter(dateFormat).invoke();
CharSequence charSequence = RequestCycle.get().urlFor(icon, null);
String timeFormat = defaultSettings.get(DefaultSettingTypeEnum.timeOnlyFormat);
String jqueryUITime = new SimpleDateFormatToJQueryUIFormatConverter(timeFormat).invoke();
options.showOn("button")
.buttonImage(charSequence)
.buttonImageOnly(true)
.dateFormat(jqueryUIDate)
.timeFormat(jqueryUITime);
return options;
}
}
public class DateTimePickerTextFieldCreator implements Serializable {
private ClientConfigBean _clientConfigBean;
private IConverter _dateConverter;
public DateTimePickerTextFieldCreator(ClientConfigBean clientConfigBean, IConverter dateConverter) {
_clientConfigBean = clientConfigBean;
_dateConverter = dateConverter;
}
public TextField<Date> invoke(final String dateInputId, final IModel<Date> model) {
DateTimePickerBehavior dateTimePickerBehavior = getDateTimePickerBehavior();
TextFieldWithCasperJsAnnotation<Date> dateTimePickerTextField = new TextFieldWithCasperJsAnnotation<Date>(dateInputId, model, Date.class) {
@Override
public <C> IConverter<C> getConverter(Class<C> type) {
return _dateConverter;
}
};
dateTimePickerTextField.add(dateTimePickerBehavior);
return dateTimePickerTextField;
}
public DateTimePickerBehavior getDateTimePickerBehavior() {
final DateTimePickerOptions dateTimePickerOptions = getDateTimePickerOptions();
return new DateTimePickerBehavior(dateTimePickerOptions) {
/**
* This hack was implemented to assign DateTimePicker to input text field in case input was loaded by ajax.
* jqWicket stands on the assumption that DateTimePicker should be initialised on DOM ready jQuery event.
* In case we use ajax input will not get initialised.
*
* @param component
*/
@Override
public void afterRender(Component component) {
super.afterRender(component);
Response response = component.getResponse();
StringBuilder script = new StringBuilder()
.append("<script>")
.append("function startDateTimePicker() {\n")
.append(" var $input = $(\"#").append(component.getMarkupId()).append("\");\n")
.append("if ($ && $.timepicker && $input.length > 0) { \n")
.append(" if (!$input.hasClass('hasDatepicker')) {")
.append(" $input.datetimepicker(").append(dateTimePickerOptions.toString()).append(");")
.append(" }")
.append(" return true;")
.append("} \n")
.append(" setTimeout(startDateTimePicker, 500);")
.append("}\n")
.append("startDateTimePicker();")
.append("</script>");
response.write(script);
}
};
}
public DateTimePickerOptions getDateTimePickerOptions() {
return new DateTimePickerOptionsCreator(_clientConfigBean).invoke();
}
}
these are working on wicket 7 as there is wicket-datetime compatible and available, but when I'm upgraded to wicket 8 this is not available so I want to move to KendoUI datetimepicker, as its best suitable (for me, m thoughts). so the invoke method return the TextField of type Date.
So I'm trying to do same.
I tried the examples from your mentioned sites but they are not upto my requirement(As I'm new to wicket and kendo as well).
Thanks, Pravin.