1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package javax.faces.internal; |
17 | |
|
18 | |
import java.util.List; |
19 | |
|
20 | |
import javax.faces.component.UIViewRoot; |
21 | |
import javax.faces.context.FacesContext; |
22 | |
import javax.servlet.jsp.PageContext; |
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
public class PageContextUtil { |
31 | |
|
32 | 0 | private PageContextUtil() { |
33 | 0 | } |
34 | |
|
35 | |
public static List getComponentTagStackAttribute(PageContext pageContext) { |
36 | 26 | return (List) pageContext.getAttribute( |
37 | |
InternalConstants.COMPONENT_TAG_STACK_ATTR, getScope()); |
38 | |
} |
39 | |
|
40 | |
public static void setComponentStackAttribute(PageContext pageContext, |
41 | |
List list) { |
42 | 8 | pageContext.setAttribute(InternalConstants.COMPONENT_TAG_STACK_ATTR, |
43 | |
list, getScope()); |
44 | 8 | } |
45 | |
|
46 | |
public static void removeComponentStackAttribute(PageContext pageContext) { |
47 | 3 | pageContext.removeAttribute(InternalConstants.COMPONENT_TAG_STACK_ATTR, |
48 | |
getScope()); |
49 | 3 | } |
50 | |
|
51 | |
private static int getScope() { |
52 | 37 | String defaultSuffix = FacesConfigOptions.getDefaultSuffix(); |
53 | 37 | return (defaultSuffix.indexOf(".htm") >= 0) ? PageContext.PAGE_SCOPE |
54 | |
: PageContext.REQUEST_SCOPE; |
55 | |
} |
56 | |
|
57 | |
public static FacesContext getCurrentFacesContextAttribute( |
58 | |
PageContext pageContext) { |
59 | 7 | return (FacesContext) pageContext |
60 | |
.getAttribute(InternalConstants.CURRENT_FACES_CONTEXT); |
61 | |
} |
62 | |
|
63 | |
public static void setCurrentFacesContextAttribute(PageContext pageContext, |
64 | |
FacesContext context) { |
65 | 7 | pageContext.setAttribute(InternalConstants.CURRENT_FACES_CONTEXT, |
66 | |
context); |
67 | 7 | } |
68 | |
|
69 | |
public static UIViewRoot getCurrentViewRootAttribute(PageContext pageContext) { |
70 | 7 | return (UIViewRoot) pageContext |
71 | |
.getAttribute(InternalConstants.CURRENT_VIEW_ROOT); |
72 | |
} |
73 | |
|
74 | |
public static void setCurrentViewRootAttribute(PageContext pageContext, |
75 | |
UIViewRoot component) { |
76 | 7 | pageContext |
77 | |
.setAttribute(InternalConstants.CURRENT_VIEW_ROOT, component); |
78 | 7 | } |
79 | |
|
80 | |
public static String getCharacterEncoding(PageContext pageContext) { |
81 | 7 | return pageContext.getRequest().getCharacterEncoding(); |
82 | |
} |
83 | |
} |