View Javadoc

1   // WARNING: This file was automatically generated. Do not edit it directly,
2   //          or you will lose your changes.
3   
4   /*
5    * Licensed to the Apache Software Foundation (ASF) under one
6    * or more contributor license agreements.  See the NOTICE file
7    * distributed with this work for additional information
8    * regarding copyright ownership.  The ASF licenses this file
9    * to you under the Apache License, Version 2.0 (the
10   * "License"); you may not use this file except in compliance
11   * with the License.  You may obtain a copy of the License at
12   *
13   *   http://www.apache.org/licenses/LICENSE-2.0
14   *
15   * Unless required by applicable law or agreed to in writing,
16   * software distributed under the License is distributed on an
17   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18   * KIND, either express or implied.  See the License for the
19   * specific language governing permissions and limitations
20   * under the License.
21  */
22  package org.apache.myfaces.trinidad.component;
23  
24  import java.util.ArrayDeque;
25  import java.util.Collections;
26  import java.util.Map;
27  import java.util.Queue;
28  import javax.faces.context.FacesContext;
29  import org.apache.myfaces.trinidad.bean.FacesBean;
30  import org.apache.myfaces.trinidad.context.ComponentContextManager;
31  import org.apache.myfaces.trinidad.context.RequestContext;
32  import org.apache.myfaces.trinidad.context.SuspendedContextChanges;
33  import org.apache.myfaces.trinidad.logging.TrinidadLogger;
34  
35  /**
36   *
37   * <h4>Events:</h4>
38   * <table border="1" width="100%" cellpadding="3" summary="">
39   * <tr bgcolor="#CCCCFF" class="TableHeadingColor">
40   * <th align="left">Type</th>
41   * <th align="left">Phases</th>
42   * <th align="left">Description</th>
43   * </tr>
44   * <tr class="TableRowColor">
45   * <td valign="top"><code>org.apache.myfaces.trinidad.event.AttributeChangeEvent</code></td>
46   * <td valign="top" nowrap>Invoke<br>Application<br>Apply<br>Request<br>Values</td>
47   * <td valign="top">Event delivered to describe an attribute change.  Attribute change events are not delivered for any programmatic change to a property.  They are only delivered when a renderer changes a property without the application's specific request.  An example of an attribute change event might include the width of a column that supported client-side resizing.</td>
48   * </tr>
49   * </table>
50   */
51  public class UIXDocument extends UIXComponentBase
52  {
53    static public final FacesBean.Type TYPE = new FacesBean.Type(
54      UIXComponentBase.TYPE);
55  
56    static public final String COMPONENT_FAMILY =
57      "org.apache.myfaces.trinidad.Document";
58    static public final String COMPONENT_TYPE =
59      "org.apache.myfaces.trinidad.Document";
60  
61    /**
62     * Construct an instance of the UIXDocument.
63     */
64    public UIXDocument()
65    {
66      super("org.apache.myfaces.trinidad.Document");
67    }
68      /**
69     * Suspends any context changes before allowing invokeOnComponent or visitTree calls to continue,
70     * allowing components to undo any context changes during a re-entrant call.
71     * @param facesContext the faces context
72     * @see ComponentContextManager#suspend(FacesContext)
73     */
74    @Override
75    protected void setupVisitingContext(FacesContext facesContext)
76    {
77      ComponentContextManager ctxMgr = RequestContext.getCurrentInstance()
78        .getComponentContextManager();
79  
80      // Suspend any current component context during a visit tree for re-entrant
81      // component tree processing
82      SuspendedContextChanges suspendedChanges = ctxMgr.suspend(facesContext);
83  
84      Map<String, Object> reqMap = facesContext.getExternalContext().getRequestMap();
85      @SuppressWarnings("unchecked")
86      Queue<SuspendedContextChanges> suspendedChangesQueue = (Queue<SuspendedContextChanges>)
87        reqMap.get(_SUSPENDED_CHANGES_KEY);
88      if (suspendedChangesQueue == null)
89      {
90        suspendedChangesQueue = Collections.asLifoQueue(new ArrayDeque<SuspendedContextChanges>());
91        reqMap.put(_SUSPENDED_CHANGES_KEY, suspendedChangesQueue);
92      }
93  
94      suspendedChangesQueue.offer(suspendedChanges);
95      _LOG.fine("UIXDocument suspended context changes in setupVisitingContext");
96  
97      super.setupVisitingContext(facesContext);
98    }
99  
100   /**
101    * Re-applies the suspended context changes.
102    * @param facesContext the faces context
103    * @see #setupVisitingContext(FacesContext)
104    * @see ComponentContextManager#resume(FacesContext, SuspendedContextChanges)
105    */
106   @Override
107   protected void tearDownVisitingContext(FacesContext facesContext)
108   {
109     super.tearDownVisitingContext(facesContext);
110 
111     ComponentContextManager ctxMgr = RequestContext.getCurrentInstance()
112       .getComponentContextManager();
113     Map<String, Object> reqMap = facesContext.getExternalContext().getRequestMap();
114     @SuppressWarnings("unchecked")
115     Queue<SuspendedContextChanges> suspendedChangesQueue = (Queue<SuspendedContextChanges>)
116       reqMap.get(_SUSPENDED_CHANGES_KEY);
117     SuspendedContextChanges changes = suspendedChangesQueue.poll();
118     ctxMgr.resume(facesContext, changes);
119     _LOG.fine("UIXDocument resumed context changes in setupVisitingContext");
120   }
121 
122   private final static String _SUSPENDED_CHANGES_KEY = UIXDocument.class.getName() +
123                                                        ".SUSPENDED_CHANGES";
124   private static final TrinidadLogger _LOG = TrinidadLogger.createTrinidadLogger(UIXDocument.class);
125 
126   @Override
127   public String getFamily()
128   {
129     return COMPONENT_FAMILY;
130   }
131 
132   @Override
133   protected FacesBean.Type getBeanType()
134   {
135     return TYPE;
136   }
137 
138   /**
139    * Construct an instance of the UIXDocument.
140    */
141   protected UIXDocument(
142     String rendererType
143     )
144   {
145     super(rendererType);
146   }
147 
148   static
149   {
150     TYPE.lockAndRegister("org.apache.myfaces.trinidad.Document","org.apache.myfaces.trinidad.Document");
151   }
152 }