1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package javax.faces.view;
20
21 import java.beans.BeanInfo;
22 import java.io.IOException;
23 import java.net.MalformedURLException;
24 import java.util.List;
25 import java.util.Map;
26 import java.util.logging.Level;
27 import java.util.logging.Logger;
28 import java.util.stream.Stream;
29
30 import javax.faces.application.Resource;
31 import javax.faces.application.ResourceVisitOption;
32 import javax.faces.application.ViewVisitOption;
33 import javax.faces.component.UIComponent;
34 import javax.faces.component.UIViewRoot;
35 import javax.faces.context.FacesContext;
36
37
38
39
40 public abstract class ViewDeclarationLanguage
41 {
42
43
44
45 public static final String JSP_VIEW_DECLARATION_LANGUAGE_ID = "java.faces.JSP";
46
47
48
49
50 public static final String FACELETS_VIEW_DECLARATION_LANGUAGE_ID = "java.faces.Facelets";
51
52 public abstract void buildView(FacesContext context, UIViewRoot view) throws IOException;
53
54 public abstract UIViewRoot createView(FacesContext context, String viewId);
55
56 public abstract BeanInfo getComponentMetadata(FacesContext context, Resource componentResource);
57
58 public abstract Resource getScriptComponentResource(FacesContext context, Resource componentResource);
59
60 public abstract StateManagementStrategy getStateManagementStrategy(FacesContext context, String viewId);
61
62 public abstract ViewMetadata getViewMetadata(FacesContext context, String viewId);
63
64 public abstract void renderView(FacesContext context, UIViewRoot view) throws IOException;
65
66 public abstract UIViewRoot restoreView(FacesContext context, String viewId);
67
68 public void retargetAttachedObjects(FacesContext context, UIComponent topLevelComponent,
69 List<AttachedObjectHandler> handlers)
70 {
71 throw new UnsupportedOperationException();
72 }
73
74 public void retargetMethodExpressions(FacesContext context, UIComponent topLevelComponent)
75 {
76 throw new UnsupportedOperationException();
77 }
78
79
80
81
82
83
84 public String getId()
85 {
86 return this.getClass().getName();
87 }
88
89
90
91
92
93
94
95
96 public boolean viewExists(FacesContext facesContext, String viewId)
97 {
98 try
99 {
100 return facesContext.getExternalContext().getResource(viewId) != null;
101 }
102 catch (MalformedURLException e)
103 {
104 Logger log = Logger.getLogger(ViewDeclarationLanguage.class.getName());
105 if (log.isLoggable(Level.SEVERE))
106 {
107 log.log(Level.SEVERE, "Malformed URL viewId: "+viewId, e);
108 }
109 }
110 return false;
111 }
112
113
114
115
116
117
118
119
120
121 public UIComponent createComponent(FacesContext context,
122 String taglibURI,
123 String tagName,
124 Map<String,Object> attributes)
125 {
126 return null;
127 }
128
129
130
131
132
133
134
135 public List<String> calculateResourceLibraryContracts(FacesContext context,
136 String viewId)
137 {
138 return null;
139 }
140
141
142
143
144
145
146
147
148 public Stream<java.lang.String> getViews(FacesContext facesContext, String path, ViewVisitOption... options)
149 {
150 return getViews(facesContext, path, Integer.MAX_VALUE, options);
151 }
152
153
154
155
156
157
158
159
160
161
162
163 public Stream<java.lang.String> getViews(FacesContext facesContext, String path,
164 int maxDepth, ViewVisitOption... options)
165 {
166
167
168
169
170
171
172
173
174 return facesContext.getApplication().getResourceHandler().getViewResources(
175 facesContext, path, maxDepth, ResourceVisitOption.TOP_LEVEL_VIEWS_ONLY);
176 }
177 }