home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / VCAFE.3.0A / Sample.bin / PHCardEntry.java < prev    next >
Text File  |  1998-10-17  |  2KB  |  83 lines

  1. package symantec.sourcebook.creditcheck;
  2. import java.io.*;
  3. import javax.servlet.*;
  4. import javax.servlet.http.*;
  5.  
  6. public class PHCardEntry extends PageHandler
  7. {
  8.  
  9.    private final static String PAGENAME = PAGEBASE + "cardentry.html";
  10.    int pagenumber = CreditCheck.SUCCESS_PAGE_NUM;
  11.  
  12.    public PHCardEntry()
  13.    {
  14.  
  15.  
  16.    }
  17.  
  18.    public String pageName()
  19.    {
  20.         return PAGENAME;
  21.    }
  22.  
  23.    public int nextPage()
  24.    {
  25.         return pagenumber;
  26.    }
  27.  
  28.  
  29.    
  30.    protected void customize(Object pageDataObject) throws IOException
  31.    {
  32.         PageData pageData = (PageData) pageDataObject;
  33.     
  34.         String orderInformation = "Name : "+ pageData.ccName + "<br>" +
  35.                                   "Total: " + pageData.ccTotal + "<br>" ;
  36.  
  37.  
  38.         String fieldText = "<input type=\"hidden\" name=\"successCGI\" value=\""+ pageData.successCGI +"\"> ";
  39.        
  40.         fieldText += orderInformation + "<input type=\"hidden\" name=\"ccTotal\" value=\""+pageData.ccTotal+"\">";
  41.         fieldText += "<input type=\"hidden\" name=\"ccName\" value=\""+pageData.ccName+"\">";
  42.         fieldText += "<input type=\"hidden\" name=\"orderId\" value=\""+pageData.orderId+"\">";
  43.                        
  44.         insert("fieldPosition",fieldText); 
  45.         
  46.         if(pageData.messageText != null) insert("posErrorText",pageData.messageText);
  47.    }
  48.  
  49.  
  50.     public Object validate(ServletConfig config,HttpServletRequest request,HttpServletResponse response)
  51.     {
  52.         PageData pageData = new PageData(config,request,response);
  53.  
  54.         String errorText = "";
  55.  
  56.         // get information from the form
  57.  
  58.         pageData.ccName     = getParameter(request,"ccName","");
  59.         pageData.ccTotal    = getParameter(request,"ccTotal","");
  60.         pageData.ccNumber   = getParameter(request,"ccNumber","");
  61.         pageData.successCGI = getParameter(request,"successCGI","");
  62.         pageData.orderId    = getParameter(request,"orderId","");
  63.         
  64.         // do some sanity checks
  65.  
  66.         if(pageData.ccNumber.length() < 2)   errorText += "Please enter card number<br>";
  67.  
  68.         // if it looks bad, bail
  69.  
  70.         if(errorText.length() > 0)
  71.         {
  72.             pagenumber = CreditCheck.CARDENTRY_PAGE_NUM;
  73.             pageData.messageText = errorText;
  74.             return pageData;
  75.         }
  76.  
  77.        
  78.         return pageData;
  79.     }
  80.  
  81.  
  82.  
  83. }