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.Facets;
23  import org.apache.myfaces.tobago.component.OnComponentPopulated;
24  import org.apache.myfaces.tobago.component.SupportsRenderedPartially;
25  import org.apache.myfaces.tobago.event.PopupFacetActionListener;
26  import org.apache.myfaces.tobago.layout.LayoutComponent;
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.event.PhaseId;
33  import java.util.Iterator;
34  
35  public abstract class AbstractUICommand
36      extends AbstractUICommandBase
37      implements SupportsRenderedPartially, OnComponentPopulated, LayoutComponent {
38  
39    public void onComponentPopulated(final FacesContext facesContext, final UIComponent parent) {
40      final AbstractUIPopup popup = (AbstractUIPopup) getFacet(Facets.POPUP);
41      if (popup != null) {
42        if (!ComponentUtils.containsPopupActionListener(this)) {
43          addActionListener(new PopupFacetActionListener());
44        }
45      }
46    }
47  
48    public void processDecodes(final FacesContext context) {
49      if (context == null) {
50        throw new NullPointerException();
51      }
52  
53      // Skip processing if our rendered flag is false
54      if (!isRendered()) {
55        return;
56      }
57  
58      // Process this component itself
59      try {
60        decode(context);
61      } catch (final RuntimeException e) {
62        context.renderResponse();
63        throw e;
64      }
65  
66      final Iterator kids = getFacetsAndChildren();
67      while (kids.hasNext()) {
68        final UIComponent kid = (UIComponent) kids.next();
69        kid.processDecodes(context);
70      }
71    }
72  
73    public void queueEvent(final FacesEvent facesEvent) {
74      // fix for TOBAGO-262
75      super.queueEvent(facesEvent);
76      if (this == facesEvent.getSource()) {
77        if (isImmediate()) {
78          facesEvent.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
79        } else {
80          facesEvent.setPhaseId(PhaseId.INVOKE_APPLICATION);
81        }
82      }
83    }
84  
85    public abstract String getLabel();
86  
87    public abstract boolean isJsfResource();
88  
89    public abstract String getResource();
90  
91    public abstract String getLink();
92  
93    public abstract String getOnclick();
94  
95    public abstract String getTarget();
96  
97    public abstract boolean isTransition();
98  
99    public abstract String[] getRenderedPartially();
100 
101   public abstract boolean isOmit();
102 
103 }