Java Reference
In-Depth Information
Figure 15-4: Form generated from the XML of Listing 15-9 using the stylesheet of listing 15-12
Caution
Bean properties are case sensitive. Use lowercase for the property names.
Note that this example only displays a small number of elements from the underlying XML. Obviously,
you can create a single large form to display the entire document for editing, or you can create a series
of smaller forms like the example in Figure 15-4 , processing them sequentially.
The JSP page required to handle the update is shown in Listing 15-13 . It simply passes the attributes
picked up from the form to the UpdateXMLBean and calls the bean's updateVehicleData()
method. On completion, the user is forwarded to the detail Web page to view the results of the change.
Listing 15-13: JSP to process the database update form
<%@ page language="java" contentType="text/html"%>
<jsp:useBean id="UpdateXMLBean"
class="JavaDatabaseBible.ch15.UpdateXMLBean" scope="session"/>
<jsp:setProperty name="UpdateXMLBean" property="*"/>
<%UpdateXMLBean.updateVehicleData();%>
<%
String id = UpdateXMLBean.getVehicleId();
String nextPage = "GetDetailPage.jsp?DetailId="+id;
%>
<jsp:forward page="<%=nextPage%>"/>
The JavaBean that updates the vehicle data is shown in Listing 15-14 . This JavaBean is similar to the
code of Listing 15-7 , with the exception that it creates an updatable ResultSet and includes a method to
perform the update.
Listing 15-14: Updatable ResultSet bean
package JavaDatabaseBible.ch15;
import java.io.*;
import java.sql.*;
import javax.sql.*;
public class MemberUpdateXMLBean{
protected static String dbUserName = "sa";
protected static String dbPassword = "dba";
protected String xmlHeader = "<?xml version=\"1.0\"?>";
Search WWH ::




Custom Search