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 javax.faces.render.RenderKitFactory;
26 import org.apache.myfaces.shared.view.ViewDeclarationLanguageBase;
27
28
29
30
31
32 public abstract class FaceletViewDeclarationLanguageBase extends ViewDeclarationLanguageBase
33 {
34
35
36
37 private static final String DYNAMIC_COMPONENT_REFRESH_TRANSIENT_BUILD = "oam.vf.DCRTB";
38
39 private static final String DYNAMIC_COMPONENT_NEEDS_REFRESH = "oam.vf.DC_NEEDS_REFRESH";
40
41 private VisitContextFactory _visitContextFactory = null;
42
43 private RenderKitFactory _renderKitFactory = null;
44
45 protected VisitContextFactory getVisitContextFactory()
46 {
47 if (_visitContextFactory == null)
48 {
49 _visitContextFactory = (VisitContextFactory)FactoryFinder.getFactory(FactoryFinder.VISIT_CONTEXT_FACTORY);
50 }
51 return _visitContextFactory;
52 }
53
54 public static boolean isDynamicComponentRefreshTransientBuildActive(FacesContext facesContext)
55 {
56 if (facesContext.getViewRoot() == null)
57 {
58 return false;
59 }
60 return Boolean.TRUE.equals(facesContext.getViewRoot().getAttributes().get(
61 DYNAMIC_COMPONENT_REFRESH_TRANSIENT_BUILD));
62 }
63
64 public static boolean isDynamicComponentRefreshTransientBuildActive(FacesContext facesContext, UIViewRoot view)
65 {
66 return Boolean.TRUE.equals(view.getAttributes().get(
67 DYNAMIC_COMPONENT_REFRESH_TRANSIENT_BUILD));
68 }
69
70 public static void activateDynamicComponentRefreshTransientBuild(FacesContext facesContext)
71 {
72 if (!isDynamicComponentRefreshTransientBuildActive(facesContext))
73 {
74 facesContext.getViewRoot().getAttributes().put(
75 DYNAMIC_COMPONENT_REFRESH_TRANSIENT_BUILD, Boolean.TRUE);
76 }
77 }
78
79 public static boolean isDynamicComponentNeedsRefresh(FacesContext context)
80 {
81 return Boolean.TRUE.equals(context.getAttributes().get(DYNAMIC_COMPONENT_NEEDS_REFRESH));
82 }
83
84 public static void dynamicComponentNeedsRefresh(FacesContext context)
85 {
86 context.getAttributes().put(DYNAMIC_COMPONENT_NEEDS_REFRESH, Boolean.TRUE);
87 }
88
89 public static void resetDynamicComponentNeedsRefreshFlag(FacesContext context)
90 {
91 context.getAttributes().put(DYNAMIC_COMPONENT_NEEDS_REFRESH, Boolean.FALSE);
92 }
93
94 protected RenderKitFactory getRenderKitFactory()
95 {
96 if (_renderKitFactory == null)
97 {
98 _renderKitFactory = (RenderKitFactory)FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
99 }
100 return _renderKitFactory;
101 }
102
103 }