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 java.io.IOException;
22 import java.util.HashMap;
23 import java.util.Map;
24
25 import javax.el.ELException;
26 import javax.faces.FacesException;
27 import javax.faces.application.Resource;
28 import javax.faces.component.UIViewRoot;
29 import javax.faces.context.FacesContext;
30 import javax.faces.context.ResponseWriter;
31
32 import org.apache.myfaces.view.facelets.compiler.Compiler;
33
34
35
36
37
38
39
40
41 public class MockFaceletViewDeclarationLanguage extends
42 FaceletViewDeclarationLanguage
43 {
44
45 private String _renderedViewId;
46 private Map<Resource, Resource> _scriptComponentResources;
47
48 public MockFaceletViewDeclarationLanguage(FacesContext context)
49 {
50 super(context);
51 }
52
53 public void buildView(FacesContext context, UIViewRoot view, String xmlFile) throws IOException
54 {
55 _renderedViewId = xmlFile;
56 buildView(context, view);
57 }
58
59 @Override
60 public String getRenderedViewId(FacesContext context, String actionId)
61 {
62 return _renderedViewId;
63 }
64
65 @Override
66 public String calculateViewId(FacesContext context, String viewId)
67 {
68 String calculatedViewId = super.calculateViewId(context, viewId);
69 if (calculatedViewId == null)
70 {
71
72 calculatedViewId = viewId;
73 }
74 return calculatedViewId;
75 }
76
77 @Override
78 public Compiler createCompiler(FacesContext context)
79 {
80 return super.createCompiler(context);
81 }
82
83 @Override
84 public FaceletFactory createFaceletFactory(FacesContext context,
85 Compiler compiler)
86 {
87 return super.createFaceletFactory(context, compiler);
88 }
89
90 @Override
91 public ResponseWriter createResponseWriter(FacesContext context)
92 throws IOException, FacesException
93 {
94 return super.createResponseWriter(context);
95 }
96
97 @Override
98 public String getDefaultSuffix(FacesContext context)
99 throws FacesException
100 {
101 return super.getDefaultSuffix(context);
102 }
103
104 @Override
105 public String getResponseContentType(FacesContext context, String orig)
106 {
107 return super.getResponseContentType(context, orig);
108 }
109
110 @Override
111 public String getResponseEncoding(FacesContext context, String orig)
112 {
113 return super.getResponseEncoding(context, orig);
114 }
115
116 @Override
117 public void handleFaceletNotFound(FacesContext context, String viewId)
118 throws FacesException, IOException
119 {
120 super.handleFaceletNotFound(context, viewId);
121 }
122
123 @Override
124 public void handleRenderException(FacesContext context, Exception e)
125 throws IOException, ELException, FacesException
126 {
127 super.handleRenderException(context, e);
128 }
129
130 @Override
131 public void initialize(FacesContext context)
132 {
133 super.initialize(context);
134 }
135
136 @Override
137 public void loadDecorators(FacesContext context, Compiler compiler)
138 {
139 super.loadDecorators(context, compiler);
140 }
141
142 @Override
143 public void loadLibraries(FacesContext context, Compiler compiler)
144 {
145 super.loadLibraries(context, compiler);
146 }
147
148 @Override
149 public void loadOptions(FacesContext context, Compiler compiler)
150 {
151 super.loadOptions(context, compiler);
152 }
153
154 @Override
155 public void sendSourceNotFound(FacesContext context, String message)
156 {
157 super.sendSourceNotFound(context, message);
158 }
159
160 @Override
161 public Resource getScriptComponentResource(FacesContext context,
162 Resource componentResource)
163 {
164 if (_scriptComponentResources != null)
165 {
166 Resource installedResource = _scriptComponentResources.get(componentResource);
167 if (installedResource != null)
168 {
169
170 return installedResource;
171 }
172 }
173 return super.getScriptComponentResource(context, componentResource);
174 }
175
176
177
178
179
180
181
182
183 public void setScriptComponentResource(Resource componentResource, Resource scriptResource)
184 {
185 if (_scriptComponentResources == null)
186 {
187 _scriptComponentResources = new HashMap<Resource, Resource>();
188 }
189 _scriptComponentResources.put(componentResource, scriptResource);
190 }
191
192
193
194
195
196
197 }