1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.portals.bridges.jsf;
17
18 import javax.faces.FacesException;
19 import javax.faces.context.FacesContext;
20 import javax.faces.context.FacesContextFactory;
21 import javax.faces.lifecycle.Lifecycle;
22
23 import javax.portlet.PortletConfig;
24 import javax.portlet.PortletContext;
25 import javax.portlet.PortletRequest;
26 import javax.portlet.PortletResponse;
27
28 /***
29 * <p>
30 * Loads the {@link PortletFacesContextImpl}
31 * </p>
32 *
33 * @author <a href="dlestrat@apache.org">David Le Strat </a>
34 */
35 public class FacesContextFactoryImpl extends FacesContextFactory
36 {
37 /***
38 * @see javax.faces.context.FacesContextFactory#getFacesContext(java.lang.Object,
39 * java.lang.Object, java.lang.Object, javax.faces.lifecycle.Lifecycle)
40 */
41 public FacesContext getFacesContext(Object config, Object request, Object response, Lifecycle lifecycle)
42 throws FacesException
43 {
44 if (config instanceof PortletConfig)
45 {
46 PortletConfig pc = (PortletConfig)config;
47 PortletContext context = pc.getPortletContext();
48 PortletFacesContextImpl facesContext = new PortletFacesContextImpl(
49 (PortletContext) context,
50 (PortletRequest) request,
51 (PortletResponse) response);
52 String defaultViewName = pc.getInitParameter(FacesPortlet.PARAM_VIEW_PAGE);
53
54 return facesContext;
55 }
56 else
57 {
58 throw new FacesException("Unsupported context type " + config.getClass().getName());
59 }
60 }
61 }