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