View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.syncope.client.ui.commons.markup.html.form;
20  
21  import com.googlecode.wicket.kendo.ui.form.datetime.AjaxDatePicker;
22  import java.util.Date;
23  import org.apache.commons.lang3.time.FastDateFormat;
24  import org.apache.wicket.model.IModel;
25  import org.apache.wicket.model.Model;
26  import org.apache.wicket.model.ResourceModel;
27  
28  public class AjaxDateFieldPanel extends DateFieldPanel {
29  
30      private static final long serialVersionUID = 1919852712185883648L;
31  
32      public AjaxDateFieldPanel(
33              final String id,
34              final String name,
35              final IModel<Date> model,
36              final FastDateFormat datePattern) {
37  
38          super(id, name, model, datePattern);
39  
40          field = new AjaxDatePicker("field", model, getLocale(), datePattern.getPattern());
41          add(field.setLabel(new ResourceModel(name, name)).setOutputMarkupId(true));
42      }
43  
44      @Override
45      public FieldPanel<Date> clone() {
46          FieldPanel<Date> panel = new AjaxDateFieldPanel(getId(), name, new Model<>(), fmt);
47          panel.setRequired(isRequired());
48          panel.setReadOnly(isReadOnly());
49          panel.setTitle(title);
50  
51          if (isRequiredLabelAdded) {
52              panel.addRequiredLabel();
53          }
54  
55          return panel;
56      }
57  }