1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.myfaces.tobago.internal.application;
21
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
24 import org.apache.myfaces.tobago.portlet.PortletUtils;
25 import org.apache.myfaces.tobago.util.DebugUtils;
26 import org.apache.myfaces.tobago.util.RequestUtils;
27
28 import javax.faces.FacesException;
29 import javax.faces.application.ViewHandler;
30 import javax.faces.component.UIViewRoot;
31 import javax.faces.context.FacesContext;
32 import java.io.IOException;
33 import java.util.Locale;
34
35
36
37
38
39
40 @Deprecated
41 public class ViewHandlerImpl extends ViewHandler {
42
43 private static final Logger LOG = LoggerFactory.getLogger(ViewHandlerImpl.class);
44
45 private ViewHandler base;
46
47 public ViewHandlerImpl(ViewHandler base) {
48 if (LOG.isInfoEnabled()) {
49 LOG.info("Hiding RI base implementation: " + base);
50 }
51 this.base = base;
52 }
53
54 public Locale calculateLocale(FacesContext facesContext) {
55 return base.calculateLocale(facesContext);
56 }
57
58 public String calculateRenderKitId(FacesContext facesContext) {
59 return base.calculateRenderKitId(facesContext);
60 }
61
62 public UIViewRoot createView(FacesContext facesContext, String viewId) {
63 if (LOG.isDebugEnabled()) {
64 LOG.debug("creating new view with viewId: '{}'", viewId);
65 }
66 UIViewRoot viewRoot = base.createView(facesContext, viewId);
67
68 if (!(viewRoot instanceof org.apache.myfaces.tobago.component.UIViewRoot)) {
69 UIViewRoot tobagoViewRoot = (UIViewRoot)
70 facesContext.getApplication().createComponent(UIViewRoot.COMPONENT_TYPE);
71 if (!(tobagoViewRoot instanceof org.apache.myfaces.tobago.component.UIViewRoot)) {
72 LOG.warn("Application creating wrong UIViewRoot, forcing Tobago");
73 tobagoViewRoot = new org.apache.myfaces.tobago.component.UIViewRoot();
74 }
75 tobagoViewRoot.setLocale(viewRoot.getLocale());
76 tobagoViewRoot.setViewId(viewId);
77 tobagoViewRoot.setRenderKitId(viewRoot.getRenderKitId());
78 viewRoot = tobagoViewRoot;
79 }
80 return viewRoot;
81 }
82
83 public String getActionURL(FacesContext facesContext, String viewId) {
84
85 if (PortletUtils.isRenderResponse(facesContext)) {
86 return PortletUtils.setViewIdForUrl(facesContext, viewId);
87 }
88
89 return base.getActionURL(facesContext, viewId);
90 }
91
92 public String getResourceURL(FacesContext facesContext, String path) {
93 return base.getResourceURL(facesContext, path);
94 }
95
96 public void renderView(FacesContext facesContext, UIViewRoot viewRoot)
97 throws IOException, FacesException {
98
99 base.renderView(facesContext, viewRoot);
100
101 if (LOG.isDebugEnabled()) {
102 LOG.debug("VIEW");
103 LOG.debug(DebugUtils.toString(facesContext.getViewRoot(), 0));
104 }
105 }
106
107 public UIViewRoot restoreView(FacesContext facesContext, String viewId) {
108 if (LOG.isDebugEnabled()) {
109 LOG.debug("restore view with viewId: '{}'", viewId);
110 }
111
112
113 RequestUtils.ensureEncoding(facesContext);
114 UIViewRoot viewRoot = base.restoreView(facesContext, viewId);
115 return viewRoot;
116 }
117
118 public void writeState(FacesContext facesContext) throws IOException {
119 base.writeState(facesContext);
120 }
121
122 }
123