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.Random;
22 import javax.faces.bean.ManagedBean;
23 import javax.faces.bean.RequestScoped;
24 import javax.faces.component.UIOutput;
25 import javax.faces.component.UIPanel;
26 import javax.faces.component.html.HtmlPanelGroup;
27
28
29
30
31 @ManagedBean(name="componentBindingFormBean")
32 @RequestScoped
33 public class ComponentBindingFormBean
34 {
35 private boolean rebuildDone = false;
36
37 private UIPanel panel;
38
39 public UIPanel getPanel()
40 {
41 if (!rebuildDone)
42 {
43 rebuildForm();
44 }
45 return panel;
46 }
47
48 public void rebuildForm()
49 {
50 if (panel == null)
51 {
52 panel = new HtmlPanelGroup();
53
54 panel.setId("formRoot");
55 }
56
57
58 panel.getChildren().clear();
59
60
61 Random random = new Random() ;
62 int n = random.nextInt(9)+1;
63
64 for(int i = 0; i < n; i++)
65 {
66 UIOutput input = new UIOutput();
67 input.setId("input_"+i);
68 panel.getChildren().add(input);
69 }
70
71 this.rebuildDone = true;
72 }
73
74 public void forceRebuild()
75 {
76 rebuildForm();
77 }
78
79 public void setPanel(UIPanel panel)
80 {
81 this.panel = panel;
82 }
83 }