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.pss.acid.managed;
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.UIPanel;
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="componentBindingVDLBean5")
37 @RequestScoped
38 public class ComponentBindingVDLBean5
39 {
40 private UIPanel panel;
41
42 public UIPanel getPanel()
43 {
44 if (panel == null)
45 {
46 panel = new HtmlPanelGroup();
47 FacesContext facesContext = FacesContext.getCurrentInstance();
48 if (facesContext.isPostback())
49 {
50
51
52
53 UIOutput out2 = new UIOutput();
54 out2.setValue("hello2");
55 panel.getChildren().add(out2);
56 }
57 UIOutput out = new UIOutput();
58 out.setValue("hello1");
59 panel.getChildren().add(out);
60
61 ViewDeclarationLanguage vdl = facesContext.getApplication().
62 getViewHandler().getViewDeclarationLanguage(
63 facesContext, facesContext.getViewRoot().getViewId());
64
65 Map<String, Object> attributes = new HashMap<String, Object>();
66 UIComponent cc = vdl.createComponent(facesContext,
67 "http://java.sun.com/jsf/composite/testComposite",
68 "dynComp_3", attributes);
69 cc.setId("ccpanel");
70
71 Map<String, Object> attributes2 = new HashMap<String, Object>();
72 UIComponent text = (UIComponent) vdl.createComponent(facesContext,
73 "http://java.sun.com/jsf/composite/testComposite",
74 "dynComp_2", attributes2);
75 text.setId("component");
76
77 cc.getChildren().add(text);
78 panel.getChildren().add(cc);
79
80 if (!facesContext.isPostback())
81 {
82
83 panel.getAttributes().put("attr1", "value1");
84 panel.getChildren().get(0).getAttributes().put("attr2", "value2");
85 }
86 else
87 {
88
89 panel.getAttributes().remove("attr1");
90 panel.getChildren().get(0).getAttributes().remove("attr2");
91 }
92 }
93 return panel;
94 }
95
96 public void setPanel(UIPanel panel)
97 {
98 this.panel = panel;
99 }
100 }