這個博客不錯,以后就呆在這里了,發一段代碼看看效果.

1
/**//*
2
* Page1.java
3
*
4
* Created on 2007年8月29日, 下午2:15
5
* Copyright hadeslee
6
*/
7
package testvisual;
8
9
import com.sun.rave.web.ui.appbase.AbstractPageBean;
10
import com.sun.webui.jsf.component.Body;
11
import com.sun.webui.jsf.component.Button;
12
import com.sun.webui.jsf.component.Form;
13
import com.sun.webui.jsf.component.Head;
14
import com.sun.webui.jsf.component.Html;
15
import com.sun.webui.jsf.component.Link;
16
import com.sun.webui.jsf.component.Message;
17
import com.sun.webui.jsf.component.Page;
18
import com.sun.webui.jsf.component.StaticText;
19
import com.sun.webui.jsf.component.TextField;
20
import javax.faces.FacesException;
21
import javax.faces.event.ValueChangeEvent;
22
import javax.faces.validator.LengthValidator;
23
24
/** *//**
25
* <p>Page bean that corresponds to a similarly named JSP page. This
26
* class contains component definitions (and initialization code) for
27
* all components that you have defined on this page, as well as
28
* lifecycle methods and event handlers where you may add behavior
29
* to respond to incoming events.</p>
30
*/
31
public class Page1 extends AbstractPageBean
{
32
// <editor-fold defaultstate="collapsed" desc="Managed Component Definition">
33
private int __placeholder;
34
35
/** *//**
36
* <p>Automatically managed component initialization. <strong>WARNING:</strong>
37
* This method is automatically generated, so any user-specified code inserted
38
* here is subject to being replaced.</p>
39
*/
40
private void _init() throws Exception
{
41
lengthValidator1.setMaximum(10);
42
lengthValidator1.setMinimum(1);
43
lengthValidator2.setMaximum(5);
44
lengthValidator2.setMinimum(1);
45
}
46
47
private Page page1 = new Page();
48
49
public Page getPage1()
{
50
return page1;
51
}
52
53
public void setPage1(Page p)
{
54
this.page1 = p;
55
}
56
57
private Html html1 = new Html();
58
59
public Html getHtml1()
{
60
return html1;
61
}
62
63
public void setHtml1(Html h)
{
64
this.html1 = h;
65
}
66
67
private Head head1 = new Head();
68
69
public Head getHead1()
{
70
return head1;
71
}
72
73
public void setHead1(Head h)
{
74
this.head1 = h;
75
}
76
77
private Link link1 = new Link();
78
79
public Link getLink1()
{
80
return link1;
81
}
82
83
public void setLink1(Link l)
{
84
this.link1 = l;
85
}
86
87
private Body body1 = new Body();
88
89
public Body getBody1()
{
90
return body1;
91
}
92
93
public void setBody1(Body b)
{
94
this.body1 = b;
95
}
96
97
private Form form1 = new Form();
98
99
public Form getForm1()
{
100
return form1;
101
}
102
103
public void setForm1(Form f)
{
104
this.form1 = f;
105
}
106
107
private Button button1 = new Button();
108
109
public Button getButton1()
{
110
return button1;
111
}
112
113
public void setButton1(Button b)
{
114
this.button1 = b;
115
}
116
117
private LengthValidator lengthValidator1 = new LengthValidator();
118
119
public LengthValidator getLengthValidator1()
{
120
return lengthValidator1;
121
}
122
123
public void setLengthValidator1(LengthValidator lv)
{
124
this.lengthValidator1 = lv;
125
}
126
127
private Message message1 = new Message();
128
129
public Message getMessage1()
{
130
return message1;
131
}
132
133
public void setMessage1(Message m)
{
134
this.message1 = m;
135
}
136
137
private TextField textField1 = new TextField();
138
139
public TextField getTextField1()
{
140
return textField1;
141
}
142
143
public void setTextField1(TextField tf)
{
144
this.textField1 = tf;
145
}
146
147
private LengthValidator lengthValidator2 = new LengthValidator();
148
149
public LengthValidator getLengthValidator2()
{
150
return lengthValidator2;
151
}
152
153
public void setLengthValidator2(LengthValidator lv)
{
154
this.lengthValidator2 = lv;
155
}
156
157
// </editor-fold>
158
159
/** *//**
160
* <p>Construct a new Page bean instance.</p>
161
*/
162
public Page1()
{
163
}
164
165
/** *//**
166
* <p>Callback method that is called whenever a page is navigated to,
167
* either directly via a URL, or indirectly via page navigation.
168
* Customize this method to acquire resources that will be needed
169
* for event handlers and lifecycle methods, whether or not this
170
* page is performing post back processing.</p>
171
*
172
* <p>Note that, if the current request is a postback, the property
173
* values of the components do <strong>not</strong> represent any
174
* values submitted with this request. Instead, they represent the
175
* property values that were saved for this view when it was rendered.</p>
176
*/
177
public void init()
{
178
// Perform initializations inherited from our superclass
179
super.init();
180
// Perform application initialization that must complete
181
// *before* managed components are initialized
182
// TODO - add your own initialiation code here
183
184
// <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
185
// Initialize automatically managed components
186
// *Note* - this logic should NOT be modified
187
try
{
188
_init();
189
} catch (Exception e)
{
190
log("Page1 Initialization Failure", e);
191
throw e instanceof FacesException ? (FacesException) e: new FacesException(e);
192
}
193
194
// </editor-fold>
195
// Perform application initialization that must complete
196
// *after* managed components are initialized
197
// TODO - add your own initialization code here
198
}
199
200
/** *//**
201
* <p>Callback method that is called after the component tree has been
202
* restored, but before any event processing takes place. This method
203
* will <strong>only</strong> be called on a postback request that
204
* is processing a form submit. Customize this method to allocate
205
* resources that will be required in your event handlers.</p>
206
*/
207
public void preprocess()
{
208
}
209
210
/** *//**
211
* <p>Callback method that is called just before rendering takes place.
212
* This method will <strong>only</strong> be called for the page that
213
* will actually be rendered (and not, for example, on a page that
214
* handled a postback and then navigated to a different page). Customize
215
* this method to allocate resources that will be required for rendering
216
* this page.</p>
217
*/
218
public void prerender()
{
219
}
220
221
/** *//**
222
* <p>Callback method that is called after rendering is completed for
223
* this request, if <code>init()</code> was called (regardless of whether
224
* or not this was the page that was actually rendered). Customize this
225
* method to release resources acquired in the <code>init()</code>,
226
* <code>preprocess()</code>, or <code>prerender()</code> methods (or
227
* acquired during execution of an event handler).</p>
228
*/
229
public void destroy()
{
230
}
231
232
/** *//**
233
* <p>返回對已限定范圍的數據 Bean 的引用。</p>
234
*/
235
protected SessionBean1 getSessionBean1()
{
236
return (SessionBean1)getBean("SessionBean1");
237
}
238
239
/** *//**
240
* <p>返回對已限定范圍的數據 Bean 的引用。</p>
241
*/
242
protected RequestBean1 getRequestBean1()
{
243
return (RequestBean1)getBean("RequestBean1");
244
}
245
246
/** *//**
247
* <p>返回對已限定范圍的數據 Bean 的引用。</p>
248
*/
249
protected ApplicationBean1 getApplicationBean1()
{
250
return (ApplicationBean1)getBean("ApplicationBean1");
251
}
252
253
public String button1_action()
{
254
// 待做事項:處理操作。返回的值是一個導航
255
// 如果名稱為 null,則返回到同一頁。
256
return "地址";
257
}
258
259
public void textField1_processValueChange(ValueChangeEvent event)
{
260
// 待做事項:替換為您的代碼
261
System.out.println("看看會調用嗎:"+event.getOldValue());
262
}
263
}
264
265


2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24


25

26

27

28

29

30

31



32

33

34

35


36

37

38

39

40



41

42

43

44

45

46

47

48

49



50

51

52

53



54

55

56

57

58

59



60

61

62

63



64

65

66

67

68

69



70

71

72

73



74

75

76

77

78

79



80

81

82

83



84

85

86

87

88

89



90

91

92

93



94

95

96

97

98

99



100

101

102

103



104

105

106

107

108

109



110

111

112

113



114

115

116

117

118

119



120

121

122

123



124

125

126

127

128

129



130

131

132

133



134

135

136

137

138

139



140

141

142

143



144

145

146

147

148

149



150

151

152

153



154

155

156

157

158

159


160

161

162



163

164

165


166

167

168

169

170

171

172

173

174

175

176

177



178

179

180

181

182

183

184

185

186

187



188

189



190

191

192

193

194

195

196

197

198

199

200


201

202

203

204

205

206

207



208

209

210


211

212

213

214

215

216

217

218



219

220

221


222

223

224

225

226

227

228

229



230

231

232


233

234

235



236

237

238

239


240

241

242



243

244

245

246


247

248

249



250

251

252

253



254

255

256

257

258

259



260

261

262

263

264

265

盡管千里冰封
依然擁有晴空
你我共同品味JAVA的濃香.