Github user svenmeier commented on a diff in the pull request: https://github.com/apache/wicket/pull/235#discussion_r142085534 --- Diff: wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/datetime/DateTimeField.java --- @@ -0,0 +1,278 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.wicket.extensions.markup.html.form.datetime; + +import java.time.LocalDate; +import java.time.LocalTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.temporal.ChronoField; +import java.util.Date; +import java.util.Locale; +import java.util.TimeZone; + +import org.apache.wicket.Session; +import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior; +import org.apache.wicket.core.request.ClientInfo; +import org.apache.wicket.markup.html.form.FormComponentPanel; +import org.apache.wicket.model.IModel; +import org.apache.wicket.protocol.http.request.WebClientInfo; + +/** + * Works on a {@link java.time.ZonedDateTime} object. Displays a date field and a DatePicker, a field + * for hours and a field for minutes, and an AM/PM field. The format (12h/24h) of the hours field + * depends on the time format of this {@link DateTimeField}'s {@link Locale}, as does the visibility + * of the AM/PM field (see {@link DateTimeField#use12HourFormat}). + * <p> + * <strong>Ajaxifying the DateTimeField</strong>: If you want to update a DateTimeField with an + * {@link AjaxFormComponentUpdatingBehavior}, you have to attach it to the contained + * {@link DateField} by overriding {@link #newDateTextField(String, IModel)} and calling + * {@link #processInput()}: + * + * <pre>{@code + * DateTimeField dateTimeField = new DateTimeField(...) { + * protected DateTextField newDateTextField(String id, PropertyModel<Date> dateFieldModel) + * { + * DateTextField dateField = super.newDateTextField(id, dateFieldModel); + * dateField.add(new AjaxFormComponentUpdatingBehavior("change") { + * protected void onUpdate(AjaxRequestTarget target) { + * processInput(); // let DateTimeField process input too + * + * ... + * } + * }); + * return recorder; + * } + * } + * }</pre> + * + * @author eelcohillenius + * @see DateField for a variant with just the date field and date picker + */ +public class DateTimeField extends FormComponentPanel<ZonedDateTime> --- End diff -- For consistency I'd prefer DateTimeField working on a LocalDateTime - for me this is the default pick instead of ZonedDateTime. Maybe we need two components, one for each type?
---