1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
30
31 public abstract class FaceletViewDeclarationLanguageBase extends ViewDeclarationLanguageBase
32 {
33
34
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 private VisitContextFactory _visitContextFactory = null;
41
42 protected VisitContextFactory getVisitContextFactory()
43 {
44 if (_visitContextFactory == null)
45 {
46 _visitContextFactory = (VisitContextFactory)FactoryFinder.getFactory(FactoryFinder.VISIT_CONTEXT_FACTORY);
47 }
48 return _visitContextFactory;
49 }
50
51 public static boolean isDynamicComponentRefreshTransientBuildActive(FacesContext facesContext)
52 {
53 if (facesContext.getViewRoot() == null)
54 {
55 return false;
56 }
57 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 return Boolean.TRUE.equals(view.getAttributes().get(
64 DYNAMIC_COMPONENT_REFRESH_TRANSIENT_BUILD));
65 }
66
67 public static void activateDynamicComponentRefreshTransientBuild(FacesContext facesContext)
68 {
69 if (!isDynamicComponentRefreshTransientBuildActive(facesContext))
70 {
71 facesContext.getViewRoot().getAttributes().put(
72 DYNAMIC_COMPONENT_REFRESH_TRANSIENT_BUILD, Boolean.TRUE);
73 }
74 }
75
76 public static boolean isDynamicComponentNeedsRefresh(FacesContext context)
77 {
78 return Boolean.TRUE.equals(context.getAttributes().get(DYNAMIC_COMPONENT_NEEDS_REFRESH));
79 }
80
81 public static void dynamicComponentNeedsRefresh(FacesContext context)
82 {
83 context.getAttributes().put(DYNAMIC_COMPONENT_NEEDS_REFRESH, Boolean.TRUE);
84 }
85
86 public static void resetDynamicComponentNeedsRefreshFlag(FacesContext context)
87 {
88 context.getAttributes().put(DYNAMIC_COMPONENT_NEEDS_REFRESH, Boolean.FALSE);
89 }
90
91 }