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