Coverage Report - org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguageBase
 
Classes in this File Line Coverage Branch Coverage Complexity
FaceletViewDeclarationLanguageBase
0%
0/17
0%
0/6
1.571
 
 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.myfaces.view.facelets;
 20  
 
 21  
 import javax.faces.FactoryFinder;
 22  
 import javax.faces.component.UIViewRoot;
 23  
 import javax.faces.component.visit.VisitContextFactory;
 24  
 import javax.faces.context.FacesContext;
 25  
 import org.apache.myfaces.shared.view.ViewDeclarationLanguageBase;
 26  
 
 27  
 /**
 28  
  *
 29  
  * @author Leonardo Uribe
 30  
  */
 31  0
 public abstract class FaceletViewDeclarationLanguageBase extends ViewDeclarationLanguageBase
 32  
 {
 33  
     /**
 34  
      * UIViewRoot attribute to check if the dynamic components in a view should be refreshed under a transient build
 35  
      */
 36  
     private static final String DYNAMIC_COMPONENT_REFRESH_TRANSIENT_BUILD = "oam.vf.DCRTB";
 37  
     
 38  
     private static final String DYNAMIC_COMPONENT_NEEDS_REFRESH = "oam.vf.DC_NEEDS_REFRESH";
 39  
     
 40  0
     private VisitContextFactory _visitContextFactory = null;
 41  
 
 42  
     protected VisitContextFactory getVisitContextFactory()
 43  
     {
 44  0
         if (_visitContextFactory == null)
 45  
         {
 46  0
             _visitContextFactory = (VisitContextFactory)FactoryFinder.getFactory(FactoryFinder.VISIT_CONTEXT_FACTORY);
 47  
         }
 48  0
         return _visitContextFactory;
 49  
     }
 50  
     
 51  
     public static boolean isDynamicComponentRefreshTransientBuildActive(FacesContext facesContext)
 52  
     {
 53  0
         if (facesContext.getViewRoot() == null)
 54  
         {
 55  0
             return false;
 56  
         }
 57  0
         return Boolean.TRUE.equals(facesContext.getViewRoot().getAttributes().get(
 58  
                 DYNAMIC_COMPONENT_REFRESH_TRANSIENT_BUILD));
 59  
     }
 60  
     
 61  
     public static boolean isDynamicComponentRefreshTransientBuildActive(FacesContext facesContext, UIViewRoot view)
 62  
     {
 63  0
         return Boolean.TRUE.equals(view.getAttributes().get(
 64  
                 DYNAMIC_COMPONENT_REFRESH_TRANSIENT_BUILD));
 65  
     }
 66  
     
 67  
     public static void activateDynamicComponentRefreshTransientBuild(FacesContext facesContext)
 68  
     {
 69  0
         if (!isDynamicComponentRefreshTransientBuildActive(facesContext))
 70  
         {
 71  0
             facesContext.getViewRoot().getAttributes().put(
 72  
                     DYNAMIC_COMPONENT_REFRESH_TRANSIENT_BUILD, Boolean.TRUE);
 73  
         }
 74  0
     }
 75  
     
 76  
     public static boolean isDynamicComponentNeedsRefresh(FacesContext context)
 77  
     {
 78  0
         return Boolean.TRUE.equals(context.getAttributes().get(DYNAMIC_COMPONENT_NEEDS_REFRESH));
 79  
     }
 80  
 
 81  
     public static void dynamicComponentNeedsRefresh(FacesContext context)
 82  
     {
 83  0
         context.getAttributes().put(DYNAMIC_COMPONENT_NEEDS_REFRESH, Boolean.TRUE);
 84  0
     }
 85  
     
 86  
     public static void resetDynamicComponentNeedsRefreshFlag(FacesContext context)
 87  
     {
 88  0
         context.getAttributes().put(DYNAMIC_COMPONENT_NEEDS_REFRESH, Boolean.FALSE);
 89  0
     }
 90  
     
 91  
 }