<% Response.ContentType = "text/vnd.wap.wml"%> <% ' This sample, WapCustomerMaint.asp, and its complement, WapCustList.asp were created using the WAP ' entry and report wizard. These two wizards are designed to work together providing a simple ' model for displaying lists of data, displaying "form" information for each line of data, and ' for editing the data. It's not easy to add, edit and deletes customers from a cell phone, but ' with a little practice it can be done. ' ' This is 100% wizard generated except for additonal comments that have been added to the page ' ' This uses the WBO oWapCustomerMaint (WapCustomerMaint.wbo). Note that we could have used the same ' WBO we use for HTML data entry and display. WML and HTML pages can share the same WBOs (after all ' the business logic is the same for both). %> <% ' ' Wap Customer Entry and Maintenance ' 'Initialize Standard Information ' Action = Save|Edit|Delete|Prev|Next|Find|Last|First ' Determines what to do with this request Action=request("Action") ' Index to use for finding records or display the list Index = Request("Index") if Index = "" then Index = 1 ' The name of the List page to be used in conjunction with this page ListURL = "WapCustList.asp" ' name of list file. If blank none. ' Name of this URL Url = Request.ServerVariables("URL") SaveError = False ' This is the ID of the current record we are working with ' RowId=request("RowId") ' Some devices have problems with Posted data. If a request URL is the same as the current URL and ' there is no querystring information (i.e. all data is POSTed) the device assumes it can ignore ' request because the data is cached. It's not. So we generate a random number and pass that on ' the query string - force the cache to be ignored Randomize: RID=int(Rnd * 1000) %>

Wap Customer Entry and Maintenance

<% ' DebugMode =1 ' uncomment this for page get/post debug help %> <% '----------------------------------------------------------- ' Process passed Request Information. ' Initialize WBOs and perform any WBO operations required '----------------------------------------------------------- ' if RowId<>""0, find it else if Edting do a clear, else find first record If RowId<>"" Then Err = oWapCustomerMaint.RequestFindbyRowId( "Customer", RowId) elseif Action="Edit" then Err = oWapCustomerMaint.RequestClear("Customer",1) else Err = oWapCustomerMaint.RequestFind("Customer",Index,FIRST_RECORD) end if ' process various Actions that might have been selected ' only support Post submissions If request("Request_method")="POST" Then oWapCustomerMaint.call "set_pbReportErrors", 0 if Action = "Save" then err = oWapCustomerMaint.RequestSave("Customer") if err = 0 then Response.Write("Customer record saved
") else Response.Write("Could not save changes. Errors Occurred
") SaveError=True ' this tells us to use the edit screen end if end if if Action = "Delete" then Err = oWapCustomerMaint.RequestDelete("Customer") if err = 0 then Response.Write("The record has been deleted.
") Action = "Next" else Response.Write("The record could not be deleted.
") end if end if ' note we use the Index variable we created above if Action = "Prev" then Err = oWapCustomerMaint.RequestFind("Customer", Index, LT) if Action = "Find" then Err = oWapCustomerMaint.RequestFind("Customer", Index, GE) if Action = "Next" then Err = oWapCustomerMaint.RequestFind("Customer", Index, GT) if Action = "First" then Err = oWapCustomerMaint.RequestFind("Customer", Index, FIRST_RECORD) if Action = "Last" then Err = oWapCustomerMaint.RequestFind("Customer", Index, LAST_RECORD) end if RowId=oWapCustomerMaint.ddValue("Customer.RowId") %> <% '----------------------------------------------------------- ' Build WML Page Display ' Data has been processed, WBOs are initialized and data is loaded. ' now use this data to build display pages. ' Depending on the status of Action and the value of SaveError ' different types of pages will be displayed. Either a data entry ' page is created, or, a data display page is created. '----------------------------------------------------------- %> <% if SaveError=False AND Action<>"Edit" then %> <% ' if we are not doing an edit or we don't have a save error (SaveError) ' we are doing a display. This is the default display mode %> Number <%=oWapCustomerMaint.DDValue("Customer.Customer_Number")%>
Customer Name <%=oWapCustomerMaint.DDValue("Customer.Name")%>
Status <%=oWapCustomerMaint.DDValue("Customer.Status")%>
Address <%=oWapCustomerMaint.DDValue("Customer.Address")%>
City <%=oWapCustomerMaint.DDValue("Customer.City")%>
St. <%=oWapCustomerMaint.DDValue("Customer.State")%>
Zip <%=oWapCustomerMaint.DDValue("Customer.Zip")%>
Phone <%=oWapCustomerMaint.DDValue("Customer.Phone_Number")%>

<% Else %> <% ' if here we are editing or correcting an edit. The record is already in the DD ' Note, if a validation error exists we show the error as part of the label %> <%FieldError=oWapCustomerMaint.DDValue("Customer.Customer_Number",DDSHORTFIELDERROR) %> Number: <% If FieldError<>"" then response.write("(" & FieldError & ") ") %> " />
<%FieldError=oWapCustomerMaint.DDValue("Customer.Name",DDSHORTFIELDERROR) %> Customer Name: <% If FieldError<>"" then response.write("(" & FieldError & ") ") %> " />
<%FieldError=oWapCustomerMaint.DDValue("Customer.Status",DDSHORTFIELDERROR) %> Status: <% If FieldError<>"" then response.write("(" & FieldError & ") ") %> " />
<%FieldError=oWapCustomerMaint.DDValue("Customer.Address",DDSHORTFIELDERROR) %> Address: <% If FieldError<>"" then response.write("(" & FieldError & ") ") %> " />
<%FieldError=oWapCustomerMaint.DDValue("Customer.City",DDSHORTFIELDERROR) %> City: <% If FieldError<>"" then response.write("(" & FieldError & ") ") %> " />
<%FieldError=oWapCustomerMaint.DDValue("Customer.State",DDSHORTFIELDERROR) %> St.: <% If FieldError<>"" then response.write("(" & FieldError & ") ") %> " />
<%FieldError=oWapCustomerMaint.DDValue("Customer.Zip",DDSHORTFIELDERROR) %> Zip: <% If FieldError<>"" then response.write("(" & FieldError & ") ") %> " />
<%FieldError=oWapCustomerMaint.DDValue("Customer.Phone_Number",DDSHORTFIELDERROR) %> Phone: <% If FieldError<>"" then response.write("(" & FieldError & ") ") %> " />

<% End if %>