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.pool;
20
21 import java.util.HashMap;
22 import java.util.Map;
23 import javax.faces.bean.ManagedBean;
24 import javax.faces.bean.RequestScoped;
25 import javax.faces.component.UIComponent;
26 import javax.faces.component.UIOutput;
27 import javax.faces.component.html.HtmlOutputText;
28 import javax.faces.component.html.HtmlPanelGroup;
29 import javax.faces.context.FacesContext;
30 import javax.faces.view.ViewDeclarationLanguage;
31
32
33
34
35
36 @ManagedBean(name="simpleRequestBean")
37 @RequestScoped
38 public class SimpleRequestBean
39 {
40
41 private HtmlPanelGroup panel1;
42
43
44 private HtmlPanelGroup panel2;
45
46
47 private HtmlPanelGroup panel3;
48
49
50 private HtmlPanelGroup panel4;
51
52 public void validateField(FacesContext context, UIComponent component, Object value)
53 {
54
55 }
56
57 public HtmlPanelGroup getPanel1()
58 {
59 if (panel1 == null)
60 {
61 panel1 = new HtmlPanelGroup();
62 }
63 return panel1;
64 }
65
66
67
68
69 public void setPanel1(HtmlPanelGroup panel1)
70 {
71 this.panel1 = panel1;
72 }
73
74 public HtmlPanelGroup getPanel2()
75 {
76 if (panel2 == null)
77 {
78 panel2 = new HtmlPanelGroup();
79 UIOutput text = new HtmlOutputText();
80 text.setValue("added component through binding");
81 panel2.getChildren().add(text);
82 }
83 return panel2;
84 }
85
86
87
88
89 public void setPanel2(HtmlPanelGroup panel2)
90 {
91 this.panel2 = panel2;
92 }
93
94
95
96
97 public HtmlPanelGroup getPanel3()
98 {
99 if (panel3 == null)
100 {
101 FacesContext facesContext = FacesContext.getCurrentInstance();
102
103 ViewDeclarationLanguage vdl = facesContext.getApplication().
104 getViewHandler().getViewDeclarationLanguage(
105 facesContext, facesContext.getViewRoot().getViewId());
106
107 panel3 = new HtmlPanelGroup();
108 Map<String, Object> attributes = new HashMap<String, Object>();
109 attributes.put("src", "/staticPageBinding3_1.xhtml");
110 UIComponent component = vdl.createComponent(facesContext,
111 "http://java.sun.com/jsf/facelets",
112 "include", attributes);
113 panel3.getChildren().add(component);
114
115 }
116 return panel3;
117 }
118
119
120
121
122 public void setPanel3(HtmlPanelGroup panel3)
123 {
124 this.panel3 = panel3;
125 }
126
127
128
129
130 public HtmlPanelGroup getPanel4()
131 {
132 if (panel4 == null)
133 {
134 FacesContext facesContext = FacesContext.getCurrentInstance();
135
136 ViewDeclarationLanguage vdl = facesContext.getApplication().
137 getViewHandler().getViewDeclarationLanguage(
138 facesContext, facesContext.getViewRoot().getViewId());
139
140 panel4 = new HtmlPanelGroup();
141
142 Map<String, Object> attributes = new HashMap<String, Object>();
143 UIComponent cc = vdl.createComponent(facesContext,
144 "http://java.sun.com/jsf/composite/testComposite",
145 "dynComp_1", attributes);
146 UIOutput text = (UIOutput) facesContext.getApplication().
147 createComponent(UIOutput.COMPONENT_TYPE);
148 text.setValue("Dynamically added header");
149 cc.getFacets().put("header", text);
150 panel4.getChildren().add(cc);
151 }
152 return panel4;
153 }
154
155
156
157
158 public void setPanel4(HtmlPanelGroup panel4)
159 {
160 this.panel4 = panel4;
161 }
162 }