A P P E N D I X  A

DiningGuide Source Files

This appendix displays the code for the following DiningGuide components:

This code is also available as source files within the DiningGuide application zip file, which you can download from the Forte for Java Developer Resources portal at:

http://forte.sun.com/ffj/documentation/tutorialsandexamples.html



Tip - If you use these files to cut and paste code into the Sun ONE Studio 5 Source Editor, all formatting is lost. To automatically reformat the code in the Source Editor, press Control-Shift F after you paste the code.





Note - Wrapped lines are copied from PDF as separate lines, causing the compiler to interpret certain types of statements as nonesense. These lines are preceeded in this code by the comment, "Join the following two lines in the Source Editor." Also, the Source Editor will mark such lines as coding errors, so they are easy to find and correct.



Solaris and Linux users are advised not to copy these files, because the Source Editor does not read the carriage returns at the ends of lines. To view source files, unzip the DiningGuide source zip file and then mount the unzipped directory in the IDE.


RestaurantBean.java Source

package Data;
 
import javax.ejb.*;
 
 
public abstract class RestaurantBean implements javax.ejb.EntityBean {
    
    private javax.ejb.EntityContext context;
    
    /**
     * @see javax.ejb.EntityBean#setEntityContext(javax.ejb.EntityContext)
     */
    public void setEntityContext(javax.ejb.EntityContext aContext) {
        context=aContext;
    }
    
    /**
     * @see javax.ejb.EntityBean#ejbActivate()
     */
    public void ejbActivate() {
        
    }
    
    /**
     * @see javax.ejb.EntityBean#ejbPassivate()
     */
    public void ejbPassivate() {
        
    }
    
    /**
     * @see javax.ejb.EntityBean#ejbRemove()
     */
    public void ejbRemove() {
        
    }
    
    /**
     * @see javax.ejb.EntityBean#unsetEntityContext()
     */
    public void unsetEntityContext() {
        context=null;
    }
    
    /**
     * @see javax.ejb.EntityBean#ejbLoad()
     */
    public void ejbLoad() {
        
    }
    
    /**
     * @see javax.ejb.EntityBean#ejbStore()
     */
    public void ejbStore() {
        
    }
    
    public abstract java.lang.String getRestaurantname();
    public abstract void setRestaurantname(java.lang.String restaurantname);
    
    public abstract java.lang.String getCuisine();
    public abstract void setCuisine(java.lang.String cuisine);
    
    public abstract java.lang.String getNeighborhood();
    public abstract void setNeighborhood(java.lang.String neighborhood);
    
    public abstract java.lang.String getAddress();
    public abstract void setAddress(java.lang.String address);
    
    public abstract java.lang.String getPhone();
    public abstract void setPhone(java.lang.String phone);
    
    public abstract java.lang.String getDescription();
    public abstract void setDescription(java.lang.String description);
    
    public abstract int getRating();
    public abstract void setRating(int rating);
    
    public java.lang.String ejbCreate(java.lang.String restaurantname, java.lang.String cuisine, java.lang.String neighborhood, java.lang.String address, java.lang.String phone, java.lang.String description, int rating) throws javax.ejb.CreateException {
        if (restaurantname == null) {
            // Join the following two lines in the Source Editor
            throw new javax.ejb.CreateException("The restaurant name is required.");
        }
        setRestaurantname(restaurantname);
        setCuisine(cuisine);
        setNeighborhood(neighborhood);
        setAddress(address);
        setPhone(phone);
        setDescription(description);
        setRating(rating);
        return null;
    }
    
    public void ejbPostCreate(java.lang.String restaurantname, java.lang.String cuisine, java.lang.String neighborhood, java.lang.String address, java.lang.String phone, java.lang.String description, int rating) throws javax.ejb.CreateException {
    }
    
    public Data.RestaurantDetail getRestaurantDetail() {
        return (new RestaurantDetail(getRestaurantname(),
        getCuisine(), getNeighborhood(), getAddress(), getPhone(),
        getDescription(), getRating()));
    }
}


RestaurantDetail.java Source

/*
 * RestaurantDetail.java
 *
 * Created on March 27, 2003, 3:35 PM
 */
 
package Data;
 
import java.beans.*;
 
public class RestaurantDetail extends Object implements java.io.Serializable {
    
    private static final String PROP_SAMPLE_PROPERTY = "SampleProperty";
    
    private String sampleProperty;
    
    private PropertyChangeSupport propertySupport;
    
    /** Holds value of property restaurantname. */
    private String restaurantname;
    
    /** Holds value of property cuisine. */
    private String cuisine;
    
    /** Holds value of property neighborhood. */
    private String neighborhood;
    
    /** Holds value of property address. */
    private String address;
    
    /** Holds value of property phone. */
    private String phone;
    
    /** Holds value of property description. */
    private String description;
    
    /** Holds value of property rating. */
    private int rating;
    
    /** Creates new RestaurantDetail */
    public RestaurantDetail() {
        propertySupport = new PropertyChangeSupport( this );
    }
    
    public RestaurantDetail(java.lang.String restaurantname, java.lang.String cuisine, java.lang.String neighborhood, java.lang.String address, java.lang.String phone, java.lang.String description, int rating) {
        System.out.println("Creating new RestaurantDetail");
        setRestaurantname(restaurantname);
        setCuisine(cuisine);
        setNeighborhood(neighborhood);
        setAddress(address);
        setPhone(phone);
        setDescription(description);
        setRating(rating);
    }
    
    public String getSampleProperty() {
        return sampleProperty;
    }
    
    public void setSampleProperty(String value) {
        String oldValue = sampleProperty;
        sampleProperty = value;
        propertySupport.firePropertyChange(PROP_SAMPLE_PROPERTY, oldValue, sampleProperty);
    }
    
    
    public void addPropertyChangeListener(PropertyChangeListener listener) {
        propertySupport.addPropertyChangeListener(listener);
    }
    
    public void removePropertyChangeListener(PropertyChangeListener listener) {
        propertySupport.removePropertyChangeListener(listener);
    }
    
    /** Getter for property restaurantname.
     * @return Value of property restaurantname.
     *
     */
    public String getRestaurantname() {
        return this.restaurantname;
    }
    
    /** Setter for property restaurantname.
     * @param restaurantname New value of property restaurantname.
     *
     */
    public void setRestaurantname(String restaurantname) {
        this.restaurantname = restaurantname;
    }
    
    /** Getter for property cuisine.
     * @return Value of property cuisine.
     *
     */
    public String getCuisine() {
        return this.cuisine;
    }
    
    /** Setter for property cuisine.
     * @param cuisine New value of property cuisine.
     *
     */
    public void setCuisine(String cuisine) {
        this.cuisine = cuisine;
    }
    
    /** Getter for property neighborhood.
     * @return Value of property neighborhood.
     *
     */
    public String getNeighborhood() {
        return this.neighborhood;
    }
    
    /** Setter for property neighborhood.
     * @param neighborhood New value of property neighborhood.
     *
     */
    public void setNeighborhood(String neighborhood) {
        this.neighborhood = neighborhood;
    }
    
    /** Getter for property address.
     * @return Value of property address.
     *
     */
    public String getAddress() {
        return this.address;
    }
    
    /** Setter for property address.
     * @param address New value of property address.
     *
     */
    public void setAddress(String address) {
        this.address = address;
    }
    
    /** Getter for property phone.
     * @return Value of property phone.
     *
     */
    public String getPhone() {
        return this.phone;
    }
    
    /** Setter for property phone.
     * @param phone New value of property phone.
     *
     */
    public void setPhone(String phone) {
        this.phone = phone;
    }
    
    /** Getter for property description.
     * @return Value of property description.
     *
     */
    public String getDescription() {
        return this.description;
    }
    
    /** Setter for property description.
     * @param description New value of property description.
     *
     */
    public void setDescription(String description) {
        this.description = description;
    }
    
    /** Getter for property rating.
     * @return Value of property rating.
     *
     */
    public int getRating() {
        return this.rating;
    }
    
    /** Setter for property rating.
     * @param rating New value of property rating.
     *
     */
    public void setRating(int rating) {
        this.rating = rating;
    }
}


CustomerreviewBean.java Source

package Data;
 
import javax.ejb.*;
 
public abstract class CustomerreviewBean implements javax.ejb.EntityBean {
    
    private javax.ejb.EntityContext context;
    
    
    /**
     * @see javax.ejb.EntityBean#setEntityContext(javax.ejb.EntityContext)
     */
    public void setEntityContext(javax.ejb.EntityContext aContext) {
        context=aContext;
    }
    
    /**
     * @see javax.ejb.EntityBean#ejbActivate()
     */
    public void ejbActivate() {
        
    }
    
    /**
     * @see javax.ejb.EntityBean#ejbPassivate()
     */
    public void ejbPassivate() {
        
    }
    
    /**
     * @see javax.ejb.EntityBean#ejbRemove()
     */
    public void ejbRemove() {
        
    }
    
    /**
     * @see javax.ejb.EntityBean#unsetEntityContext()
     */
    public void unsetEntityContext() {
        context=null;
    }
    
    /**
     * @see javax.ejb.EntityBean#ejbLoad()
     */
    public void ejbLoad() {
        
    }
    
    /**
     * @see javax.ejb.EntityBean#ejbStore()
     */
    public void ejbStore() {
        
    }
    
    public abstract java.lang.String getRestaurantname();
    public abstract void setRestaurantname(java.lang.String restaurantname);
    
    public abstract java.lang.String getCustomername();
    public abstract void setCustomername(java.lang.String customername);
    
    public abstract java.lang.String getReview();
    public abstract void setReview(java.lang.String review);
    
    public Data.CustomerreviewKey ejbCreate(java.lang.String restaurantname, java.lang.String customername, java.lang.String review) throws javax.ejb.CreateException {
        if ((restaurantname == null) || (customername == null)) {
            // Join the following two lines in the Source Editor
            throw new javax.ejb.CreateException("Both the restaurant name and customer name are required.");
        }
        setRestaurantname(restaurantname);
        setCustomername(customername);
        setReview(review);
        return null;
    }
    
    public void ejbPostCreate(java.lang.String restaurantname, java.lang.String customername, java.lang.String review) throws javax.ejb.CreateException {
    }
    
    public Data.CustomerreviewDetail getCustomerreviewDetail() {
        return (new CustomerreviewDetail(getRestaurantname(),
        getCustomername(), getReview()));
    }
}


CustomerreviewDetail.java Source

 * CustomerreviewDetail.java
 *
 * Created on March 27, 2003, 3:35 PM
 */
 
package Data;
 
import java.beans.*;
 
public class CustomerreviewDetail extends Object implements java.io.Serializable {
    
    private static final String PROP_SAMPLE_PROPERTY = "SampleProperty";
    
    private String sampleProperty;
    
    private PropertyChangeSupport propertySupport;
    
    /** Holds value of property restaurantname. */
    private String restaurantname;
    
    /** Holds value of property customername. */
    private String customername;
    
    /** Holds value of property review. */
    private String review;
    
    /** Creates new CustomerreviewDetail */
    public CustomerreviewDetail() {
        propertySupport = new PropertyChangeSupport( this );
    }
    
    public CustomerreviewDetail(java.lang.String restaurantname, java.lang.String customername, java.lang.String review) {
        System.out.println("Creating new CustomerreviewDetail");
        setRestaurantname(restaurantname);
        setCustomername(customername);
        setReview(review);
    }
    
    public String getSampleProperty() {
        return sampleProperty;
    }
    
    public void setSampleProperty(String value) {
        String oldValue = sampleProperty;
        sampleProperty = value;
        propertySupport.firePropertyChange(PROP_SAMPLE_PROPERTY, oldValue, sampleProperty);
    }
    
    public void addPropertyChangeListener(PropertyChangeListener listener) {
        propertySupport.addPropertyChangeListener(listener);
    }
    
    public void removePropertyChangeListener(PropertyChangeListener listener) {
        propertySupport.removePropertyChangeListener(listener);
    }
    
    /** Getter for property restaurantname.
     * @return Value of property restaurantname.
     *
     */
    public String getRestaurantname() {
        return this.restaurantname;
    }
    
    /** Setter for property restaurantname.
     * @param restaurantname New value of property restaurantname.
     *
     */
    public void setRestaurantname(String restaurantname) {
        this.restaurantname = restaurantname;
    }
    
    /** Getter for property customername.
     * @return Value of property customername.
     *
     */
    public String getCustomername() {
        return this.customername;
    }
    
    /** Setter for property customername.
     * @param customername New value of property customername.
     *
     */
    public void setCustomername(String customername) {
        this.customername = customername;
    }
    
    /** Getter for property review.
     * @return Value of property review.
     *
     */
    public String getReview() {
        return this.review;
    }
    
    /** Setter for property review.
     * @param review New value of property review.
     *
     */
    public void setReview(String review) {
        this.review = review;
    }
}


DiningGuideManagerBean.java Source

package Data;
 
import javax.ejb.*;
import javax.naming.*;
 
public class DiningGuideManagerBean implements javax.ejb.SessionBean {
    private javax.ejb.SessionContext context;
    private RestaurantHome myRestaurantHome;
    private CustomerreviewHome myCustomerreviewHome;
    
    /**
     * @see javax.ejb.SessionBean#setSessionContext(javax.ejb.SessionContext)
     */
    public void setSessionContext(javax.ejb.SessionContext aContext) {
        context=aContext;
    }
    
    /**
     * @see javax.ejb.SessionBean#ejbActivate()
     */
    public void ejbActivate() {
        
    }
    
    /**
     * @see javax.ejb.SessionBean#ejbPassivate()
     */
    public void ejbPassivate() {
        
    }
    
    /**
     * @see javax.ejb.SessionBean#ejbRemove()
     */
    public void ejbRemove() {
        
    }
    
    /**
     * See section 7.10.3 of the EJB 2.0 specification
     */
    public void ejbCreate() {
        System.out.println("Entering DiningGuideManagerEJB.ejbCreate()");
        Context c = null;
        Object result = null;
        if (this.myRestaurantHome == null) {
            try {
                c = new InitialContext();
                result = c.lookup("java:comp/env/ejb/Restaurant");
                myRestaurantHome = (RestaurantHome)javax.rmi.PortableRemoteObject.narrow(result, RestaurantHome.class);
            }
            catch (Exception e) {System.out.println("Error: "+
            e); }
        }
        Context crc = null;
        Object crresult = null;
        if (this.myCustomerreviewHome == null) {
            try {
                crc = new InitialContext();
                result = crc.lookup("java:comp/env/ejb/Customerreview");
                myCustomerreviewHome = (CustomerreviewHome)javax.rmi.PortableRemoteObject.narrow(result, CustomerreviewHome.class);
            }
            catch (Exception e) {System.out.println("Error: "+
            e); }
        }
        
    }
    
    public java.util.Vector getAllRestaurants() {
        System.out.println("Entering DiningGuideManagerEJB.getAllRestaurants()");
        java.util.Vector restaurantList = new java.util.Vector();
        try {
            java.util.Collection rl = myRestaurantHome.findAll();
            if (rl == null) { restaurantList = null; }
            else {
                RestaurantDetail rd;
                java.util.Iterator rli = rl.iterator();
                while ( rli.hasNext() ) {
                    rd = ((Restaurant)rli.next()).getRestaurantDetail();
                    System.out.println(rd.getRestaurantname());
                    System.out.println(rd.getRating());
                    restaurantList.addElement(rd);
                }
            }
        }
        catch (Exception e) {
            // Join the following two lines in the Source Editor
            System.out.println("Error in DiningGuideManagerEJB.getAllRestaurants(): " + e);
        }
        // Join the following two lines in the Source Editor
        System.out.println("Leaving DiningGuideManagerEJB.getAllRestaurants()");
        return restaurantList;
    }
    
    public java.util.Vector getCustomerreviewsByRestaurant(java.lang.String restaurantname) {
        System.out.println("Entering DiningGuideManagerEJB.getCustomerreviewsByRestaurant()");
        java.util.Vector reviewList = new java.util.Vector();
        try {
            java.util.Collection rl = myCustomerreviewHome.findByRestaurantName(restaurantname);
            if (rl == null) { reviewList = null; }
            else {
                CustomerreviewDetail crd;
                java.util.Iterator rli = rl.iterator();
                while ( rli.hasNext() ) {
                    crd = ((Customerreview)rli.next()).getCustomerreviewDetail();
                    System.out.println(crd.getRestaurantname());
                    System.out.println(crd.getCustomername());
                    System.out.println(crd.getReview());
                    reviewList.addElement(crd);
                }
            }
        }
        catch (Exception e) {
            // Join the following two lines in the Source Editor
            System.out.println("Error in DiningGuideManagerEJB.getCustomerreviewsByRestaurant(): " + e);
        }
        // Join the following two lines in the Source Editor
        System.out.println("Leaving DiningGuideManagerEJB.getCustomerreviewsByRestaurant()");
        return reviewList;
    }
    
    public void createCustomerreview(java.lang.String restaurantname, java.lang.String customername, java.lang.String review) {
        System.out.println("Entering  DiningGuideManagerEJB.createCustomerreview()");
        try {
            Customerreview customerrev = myCustomerreviewHome.create(restaurantname, customername,
            review);
        } catch (Exception e) {
            // Join the following two lines in the Source Editor
            System.out.println("Error in DiningGuideManagerEJB.createCustomerreview(): " + e);
        }
        // Join the following two lines in the Source Editor
        System.out.println("Leaving DiningGuideManagerEJB.createCustomerreview()");
    }
    
    public Data.RestaurantDetail getRestaurantDetail() {
        return null;
    }
    
    public Data.CustomerreviewDetail getCustomerreviewDetail() {
        return null;
    }
}


RestaurantTable.java Source

/*
 * RestaurantTable.java
 *
 * Created on March 12, 2003, 4:29 PM
 */
 
package Client;
import javax.swing.table.*;
import java.util.*;
import WebService.DGWebServiceClientGenClient.*;
/**
 *
 * @author administrator
 */
public class RestaurantTable extends javax.swing.JFrame {
    /** Creates new form RestaurantTable */
    public RestaurantTable() {
        initComponents();
        restaurantList=getAllRestaurants();
        putDataToTable();
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    private void initComponents() {//GEN-BEGIN:initComponents
        jButton1 = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jLabel1 = new javax.swing.JLabel();
        getContentPane().setLayout(new
        org.netbeans.lib.awtextra.AbsoluteLayout());
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                exitForm(evt);
            }
        });
        jButton1.setText("View Customer Comments");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton1, new
        org.netbeans.lib.awtextra.AbsoluteConstraints(200, 240, -1, -1));
        TableModel = (new javax.swing.table.DefaultTableModel(
        new Object [][] {
        },
        new String [] {
            "RESTAURANT NAME", "CUISINE", "NEIGHBORHOOD", "ADDRESS", "PHONE",
            "DESCRIPTION", "RATING"
        }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class,
                java.lang.String.class,
                java.lang.String.class,java.lang.String.class,java.lang.String.class,java.lang
                .String.class
            };
            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        jTable1.setModel(TableModel);
        jScrollPane1.setViewportView(jTable1);
        getContentPane().add(jScrollPane1, new
        org.netbeans.lib.awtextra.AbsoluteConstraints(0, 60, 600, 100));
        jLabel1.setText("Restaurant Listing");
        getContentPane().add(jLabel1, new
        org.netbeans.lib.awtextra.AbsoluteConstraints(230, 20, 110, 30));
        pack();
    }//GEN-END:initComponents
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        int r =jTable1.getSelectedRow();
        int c = jTable1.getSelectedColumnCount();
        String i =(String)TableModel.getValueAt(r,0);
        CustomerReviewTable crt = new CustomerReviewTable();
        crt.putDataToTable(i);
        crt.show();
        System.out.println(i);
    }//GEN-LAST:event_jButton1ActionPerformed
    /** Exit the Application */
    private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
        System.exit(0);
    }//GEN-LAST:event_exitForm
    private void putDataToTable() {
        Iterator j=restaurantList.iterator();
        while (j.hasNext()) {
            RestaurantDetail ci = (RestaurantDetail)j.next();
            String strRating = null;
            String[] str =
            {ci.getRestaurantname(),ci.getCuisine(),ci.getNeighborhood(),ci.getAddress(),
             ci.getPhone(),ci.getDescription(),
             strRating.valueOf(ci.getRating()),
            };
            TableModel.addRow(str);
        }
    }
    private Vector getAllRestaurants() {
        Vector restList = new Vector();
        try {
            WebService.DGWebServiceClientGenClient.DGWebService service1 = new
            WebService.DGWebServiceClientGenClient.DGWebService_Impl();
            WebService.DGWebServiceClientGenClient.DGWebServiceServantInterface port
            =
            service1.getDGWebServiceServantInterfacePort();
            restList = (java.util.Vector)port.getAllRestaurants();
        }
        catch (Exception ex) {
            System.err.println("Caught an exception." );
            ex.printStackTrace();
        }
        return restList;
    }
    private Vector getCustomerreviewByRestaurant(java.lang.String
    restaurantname) {
        Vector reviewList = new Vector();
        try {
            WebService.DGWebServiceClientGenClient.DGWebService service2 = new
            WebService.DGWebServiceClientGenClient.DGWebService_Impl();
            WebService.DGWebServiceClientGenClient.DGWebServiceServantInterface port
            =
            service2.getDGWebServiceServantInterfacePort();
            reviewList =
            (java.util.Vector)port.getCustomerreviewsByRestaurant(restaurantname);
        }
        catch (Exception ex) {
            System.err.println("Caught an exception." );
            ex.printStackTrace();
        }
        return reviewList;
    }
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        new RestaurantTable().show();
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JLabel jLabel1;
    // End of variables declaration//GEN-END:variables
    private DefaultTableModel TableModel;
    private java.util.Vector restaurantList = null;
}


CustomerReviewTable.java Source

/*
 * CustomerReviewTable.java
 *
 * Created on March 12, 2003, 4:29 PM
 */
 
package Client;
import javax.swing.table.*;
import java.util.*;
import WebService.DGWebServiceClientGenClient.*;
/**
 *
 ** @author administrator
 */
public class CustomerReviewTable extends javax.swing.JFrame {
    /** Creates new form CustomerReviewTable */
    public CustomerReviewTable() {
        initComponents();
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    private void initComponents() {//GEN-BEGIN:initComponents
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jButton1 = new javax.swing.JButton();
        customerNameLabel = new javax.swing.JLabel();
        customerNameField = new javax.swing.JTextField();
        reviewLabel = new javax.swing.JLabel();
        reviewField = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        getContentPane().setLayout(new
        org.netbeans.lib.awtextra.AbsoluteLayout());
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                exitForm(evt);
            }
        });
        TableModel = (new javax.swing.table.DefaultTableModel(
        new Object [][] {
        },
        new String [] {
            "CUSTOMER NAME", "REVIEW"
        }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class,java.lang.String.class
            };
            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        jTable1.setModel(TableModel);
        jScrollPane1.setViewportView(jTable1);
        getContentPane().add(jScrollPane1, new
        org.netbeans.lib.awtextra.AbsoluteConstraints(0, 60, 400, 100));
        jButton1.setText("Submit Customer Review");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton1, new
        org.netbeans.lib.awtextra.AbsoluteConstraints(100, 250, 190, -1));
        customerNameLabel.setText("Customer Name");
        getContentPane().add(customerNameLabel, new
        org.netbeans.lib.awtextra.AbsoluteConstraints(40, 170, -1, -1));
        getContentPane().add(customerNameField, new
        org.netbeans.lib.awtextra.AbsoluteConstraints(153, 170, 170, -1));
        reviewLabel.setText("Review");
        getContentPane().add(reviewLabel, new
        org.netbeans.lib.awtextra.AbsoluteConstraints(40, 200, 80, -1));
        getContentPane().add(reviewField, new
        org.netbeans.lib.awtextra.AbsoluteConstraints(153, 200, 170, 20));
        jLabel1.setText("All Customer Review By Restaurant Name");
        getContentPane().add(jLabel1, new
        org.netbeans.lib.awtextra.AbsoluteConstraints(80, 10, 240, -1));
        pack();
    }//GEN-END:initComponents
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_jButton1ActionPerformed
        try {
            WebService.DGWebServiceClientGenClient.DGWebService service1 = new
            WebService.DGWebServiceClientGenClient.DGWebService_Impl();
            WebService.DGWebServiceClientGenClient.DGWebServiceServantInterface
            port =
            service1.getDGWebServiceServantInterfacePort();
            port.createCustomerreview(RestaurantName,
            customerNameField.getText(),reviewField.getText());
        }
        catch (Exception ex) {
            System.err.println("Caught an exception." );
            ex.printStackTrace();
        }
        refreshView();
    }//GEN-LAST:event_jButton1ActionPerformed
    void refreshView() {
        try{
            while(TableModel.getRowCount()>0) {
                TableModel.removeRow(0);
            }
            putDataToTable(RestaurantName);
            repaint();
        }
        catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    /** Exit the Application */
    private void exitForm(java.awt.event.WindowEvent evt) {//GENFIRST:event_exitForm
        System.exit(0);
    }//GEN-LAST:event_exitForm
    public void putDataToTable(java.lang.String restaurantname) {
        RestaurantName = restaurantname;
        java.util.Vector customerList =getCustomerReviewByName(restaurantname);
        Iterator j=customerList.iterator();
        while (j.hasNext()) {
            CustomerreviewDetail ci = (CustomerreviewDetail)j.next();
            String[] str = {ci.getCustomername(),ci.getReview()
            };
            TableModel.addRow(str);
        }
    }
    private Vector getCustomerReviewByName(java.lang.String restaurantname) {
        Vector custList = new Vector();
        try {
            WebService.DGWebServiceClientGenClient.DGWebService service2 = new
            WebService.DGWebServiceClientGenClient.DGWebService_Impl();
            WebService.DGWebServiceClientGenClient.DGWebServiceServantInterface
            port =
            service2.getDGWebServiceServantInterfacePort();
            custList =
            (java.util.Vector)port.getCustomerreviewsByRestaurant(restaurantname);
        }
        catch (Exception ex) {
            System.err.println("Caught an exception." );
            ex.printStackTrace();
        }
        return custList;
    }
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        new CustomerReviewTable().show();
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel reviewLabel;
    private javax.swing.JButton jButton1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField customerNameField;
    private javax.swing.JTable jTable1;
    private javax.swing.JLabel customerNameLabel;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JTextField reviewField;
    // End of variables declaration//GEN-END:variables
    private DefaultTableModel TableModel;
    private java.lang.String RestaurantName = null;
    //private java.util.Vector restaurantList = null;
}