js to the JSP file input.jsp.
Position the cursor in the element in input.jsp and drag
and dropt input.js from the Application Navigator. A
element gets added to input.jsp. Modify the element to add a
type attribute.
We also need to modify the catalog.jsp, which is the JSP that gets
displayed if a catalog entry gets created. Add the following scritplet to
catalog.jsp.
<%out.println(???Catalog Entry Created???); %>
Similarly, to the error.jsp add scriptlet that outputs an error message.
<%out.println(???Error in creating Catalog Entry???); %>
Select File>Save All to save all the Ajax application files. Next, we
shall run the Ajax web application in JDeveloper 11g. Right-click on the
input.jsp file in Application Navigator, and select Run as shown in Fig.
2.13.
40 2 Developing an Ajax Web Application
Fig. 2.13 Running Ajax Web Application
The input form gets displayed. Start adding data to Catalog Id field. An
XMLHttpRequest gets sent to the server to verify the validity of the
data being added. If the Catalog Id field value is valid, a ???Catalog Id is
Valid??? message gets displayed as shown in Fig. 2.14.
Fig. 2.14 Validating Catalog Id
2.5 Processing an Ajax Response 41
An XMLHttpRequest request gets sent with each modification to
the Catalog Id input field as shown in Fig.
Pages:
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