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  
20  package org.apache.myfaces.tobago.internal.component;
21  
22  import org.apache.myfaces.tobago.component.Attributes;
23  import org.apache.myfaces.tobago.component.Facets;
24  import org.apache.myfaces.tobago.component.OnComponentCreated;
25  import org.apache.myfaces.tobago.config.TobagoConfig;
26  import org.apache.myfaces.tobago.renderkit.RendererBase;
27  import org.apache.myfaces.tobago.util.ComponentUtils;
28  
29  import javax.faces.component.UIComponent;
30  import javax.faces.context.FacesContext;
31  import javax.faces.event.FacesEvent;
32  import javax.faces.render.Renderer;
33  
34  /**
35   * @deprecated Since 2.0.0. It's no longer needed, because this is resolved by JavaScript now.
36   * Set backward compatibility mode via classic-date-time-picker.
37   */
38  @Deprecated
39  public abstract class AbstractUIDatePicker extends AbstractUILink implements OnComponentCreated {
40  
41    public abstract String getFor();
42  
43    public abstract void setDisabled(boolean disabled);
44  
45    public UIComponent getForComponent() {
46      ComponentUtils.evaluateAutoFor(this, AbstractUIDate.class);
47      return ComponentUtils.findFor(this);
48    }
49  
50    public void broadcast(final FacesEvent facesEvent) {
51  
52      if (!TobagoConfig.getInstance(FacesContext.getCurrentInstance()).isClassicDateTimePicker()) {
53        return;
54      }
55  
56      final FacesContext facesContext = FacesContext.getCurrentInstance();
57      final UIComponent popup = (UIComponent) getFacets().get(Facets.POPUP);
58      final String clientId = getForComponent().getClientId(facesContext);
59      final UIComponent box = popup.findComponent("box");
60      final UIComponent calendar = box.findComponent("calendar");
61      calendar.getAttributes().put(Attributes.DATE_INPUT_ID, clientId);
62      final UIComponent time = box.findComponent("time");
63      if (time != null) {
64        time.getAttributes().put(Attributes.DATE_INPUT_ID, clientId);
65      }
66      super.broadcast(facesEvent);
67    }
68  
69    public void onComponentCreated(final FacesContext facesContext, final UIComponent parent) {
70  
71      if (!TobagoConfig.getInstance(facesContext).isClassicDateTimePicker()) {
72        return;
73      }
74  
75      final Renderer renderer = getRenderer(getFacesContext());
76      if (renderer instanceof RendererBase) {
77        ((RendererBase) renderer).onComponentCreated(facesContext, this, parent);
78      }
79    }
80  
81    public String getLabel() {
82      return null;
83    }
84  
85    public Character getAccessKey() {
86      return null;
87    }
88  
89    public String getTarget() {
90      return null;
91    }
92  
93    public boolean isTransition() {
94      return true;
95    }
96  
97    public boolean isOmit() {
98      return false;
99    }
100 }