Java Reference
In-Depth Information
24 }
25
26
public void
setSsn(String ssn) {
27
this
.ssn = ssn;
28 }
29
30
public
String getAgeString() {
31
return
ageString;
32 }
33
34
public void
setAgeString(String ageString) {
35
this
.ageString = ageString;
36 }
37
38
public
String getHeightString() {
39
return
heightString;
40 }
41
42
public void
setHeightString(String heightString) {
43
this
.heightString = heightString;
44 }
45
46
public
String getResponse() {
47
if
(name ==
null
|| ssn ==
null
|| ageString ==
null
48 || heightString ==
null
) {
49
return
""
;
some input not set
50 }
51
else
{
52
return
"You entered "
+
53
" Name: "
+ name +
54
" SSN: "
+ ssn +
55
" Age: "
+ ageString +
56
" Height: "
+ heightString;
57 }
58 }
59 }
If an input is invalid, its value is not set to the bean. So only when all input are correct, the
getResponse()
method will return all input values (lines 46-58)
33.17
✓
✓
Write a tag that validates an input text with minimal length of
2
and maximum
12
.
Check
33.18
Write a tag that validates an input text for SSN using a regular expression.
Point
33.19
Write a tag that validates an input text for a double value with minimal
4.5
and
maximum
19.9
.
33.20
Write a tag that validates an input text for an integer value with minimal
4
and
maximum
20
.
33.21
Write a tag that makes an input text required.
You can bind a database in JSF applications.
Key
Point
Often you need to access a database from a Web page. This section gives examples of building
Web applications using databases.
Consider the following example that lets the user choose a course, as shown in Figure 33.18.
After a course is selected in the combo box, the students enrolled in the course are displayed
in the table, as shown in Figure 33.19. In this example, all the course titles in the
Course
table
Search WWH ::
Custom Search