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.component;
20
21 import javax.faces.component.FacesComponent;
22 import javax.faces.component.UIComponentBase;
23 import javax.faces.component.UIViewRoot;
24 import javax.faces.component.html.HtmlInputText;
25 import javax.faces.context.FacesContext;
26 import javax.faces.event.AbortProcessingException;
27 import javax.faces.event.PreRenderViewEvent;
28 import javax.faces.event.SystemEvent;
29 import javax.faces.event.SystemEventListener;
30
31 @FacesComponent(value = "com.myapp.UIStableComponent")
32 public class UIStableComponent extends UIComponentBase implements
33 SystemEventListener
34 {
35
36
37
38
39
40 public UIStableComponent()
41 {
42
43 setRendererType("testcomponent");
44
45 FacesContext context = FacesContext.getCurrentInstance();
46 UIViewRoot root = context.getViewRoot();
47
48 root.subscribeToViewEvent(PreRenderViewEvent.class, this);
49 }
50
51
52
53
54
55 @Override
56 public String getFamily()
57 {
58
59 return "com.myapp";
60 }
61
62 public boolean isListenerForSource(Object source)
63 {
64
65 return (source instanceof UIViewRoot);
66 }
67
68 public void processEvent(SystemEvent event) throws AbortProcessingException
69 {
70
71 if (FacesContext.getCurrentInstance().isPostback())
72 {
73 return;
74 }
75
76 if (FacesContext.getCurrentInstance().getMaximumSeverity() != null)
77 {
78 return;
79 }
80
81 HtmlInputText inputText1 = new HtmlInputText();
82 inputText1.setValue("1");
83 getChildren().add(inputText1);
84
85 HtmlInputText inputText2 = new HtmlInputText();
86 inputText2.setValue("2");
87 getChildren().add(inputText2);
88
89 HtmlInputText inputText3 = new HtmlInputText();
90 inputText3.setId("text3");
91 inputText3.setRequired(true);
92 getChildren().add(inputText3);
93 }
94 }