Java Reference
In-Depth Information
99
return
"<p style=\"color:red\">You entered <br />"
+
100
"Last Name: "
+ lastName +
"<br />"
+
101
"First Name: "
+ firstName +
"<br />"
+
102
"MI: "
+ mi +
"<br />"
+
103
"Gender: "
+ gender +
"<br />"
+
104
"Major: "
+ major +
"<br />"
+
105
"Minor: "
+ allMinor +
"<br />"
+
106
"Hobby: "
+ allHobby +
"<br />"
+
107
"Remarks: "
+ remarks +
"</p>"
;
108 }
109 }
110 }
The
RegistrationJSFBean
class is a managed bean that defines the properties
lastName
,
firstName
,
mi
,
gender
,
major
,
minor
, and
remarks
, which will be bound to the elements
in the JSF registration form.
The registration form can now be revised as shown in Listing 33.6. FigureĀ 33.13 shows that
new JSF page displays the user input upon clicking the
Register
button.
bean properties
L
ISTING
33.6
ProcessStudentRegistrationForm.xhtml
1 <?xml version='1.0' encoding='UTF-8' ?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml"
5 xmlns:h="http://xmlns.jcp.org/jsf/html"
6 xmlns:f="http://xmlns.jcp.org/jsf/core">
7 <h:head>
8 <title>Student Registration Form</title>
9 </h:head>
10 <h:body>
11 <h:form>
12 <!-- Use h:graphicImage -->
13 <h3>Student Registration Form
14 <h:graphicImage name="usIcon.gif" library="image"/>
15 </h3>
16
17 <!-- Use h:panelGrid -->
18 <h:panelGrid columns="6" style="color:green">
19 <h:outputLabel value="Last Name"/>
20 <h:inputText id="lastNameInputText"
21 value="#{registration.lastName}"/>
22 <h:outputLabel value="First Name" />
23 <h:inputText id="firstNameInputText"
24 value="#{registration.firstName}"/>
25 <h:outputLabel value="MI" />
26 <h:inputText id="miInputText" size="1"
27
jsf core namespace
bind
lastName
bind
firstName
value="#{registration.mi}"/>
bind
mi
28 </h:panelGrid>
29
30 <!-- Use radio buttons -->
31 <h:panelGrid columns="2">
32 <h:outputLabel>Gender </h:outputLabel>
33 <h:selectOneRadio id="genderSelectOneRadio"
34 value="#{registration.gender}">
35 <f:selectItem itemValue="Male"
36 itemLabel="Male"/>
37 <f:selectItem itemValue="Female"
38 itemLabel="Female"/>
39 </h:selectOneRadio>
bind
gender
Search WWH ::
Custom Search