Code Examples
  Home arrow Code Examples arrow WAP validation or Wapalidation by Michael ...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
CODE EXAMPLES

WAP validation or Wapalidation by Michael Wright
By: aspfree
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 3
    2000-11-07

    Table of Contents:

    Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Validate your WAP pages with Wapalidate

    Many of the unsupported characters within WAP pages are created using website contributors whereby users (webmasters etc) add content via WEB forms which transform custom MS Word characters into HTML code characters e.g. &#8216. These HTML code characters are then stored in databases which when displayed on WAP pages can create compilation errors.

    Wapalidate is a function that can be used to validate strings or database fields so that they compile correctly. This will hopefully help WAP developers to lower the chances of compilation errors and using the same databases for both WEB and WAP sites.

    Here is the code:

    Function Wapalidate(strToCheck)

    ' Replace unsupported characters e.g. HTML code characters

    strToCheck = Replace(strToCheck,"‘","'")

    strToCheck = Replace(strToCheck,"’","'")

    strToCheck = Replace(strToCheck,"“","'")

    strToCheck = Replace(strToCheck,"”","'")

    strToCheck = Replace(strToCheck,"–","-")

    strToCheck = Replace(strToCheck," ","&")

    strToCheck = Replace(strToCheck,"&"," ")

    ' Use the above line to add extra unsupported characters

    ' Replace(strToCheck,"CHANGE THIS","AND WHAT IT WILL BECOME")

    Wapalidate = strToCheck

    End Function

     

    To use the function:

    Wapalidate(VARIABLE NAME) e.g. Wapalidate(Article)

    Wapalidate(FIELD NAME) e.g. Wapalidate(rs("Article"))

    Another way to avoid compilation errors is to make sure that if you are retrieving a large amount of data from a database, that it will not make the output WAP page more than 1440 bytes.

    Here is a snippet of my code:

    LOS = Len(Article)

    ' Display Headline

    %>

    <p align="left"><small><b><%=Headline%></b></small></p>

    <%

    ‘ Display Article

    ' If there are more than 500 characters in string

    nospace = 0

    If LOS > 500 Then ‘ change 500 to anything you like but think about the 1440 bytes per page

    chars = 500 ‘ change 500 to the same as above

    Do while nospace = 0

    ' Retrieve characters from article

    tempArticle = Left(Article,chars)

    If Right(tempArticle,1) = " " then

    nospace = 1

    ' Set tempArticle to Article

    Article = tempArticle

    Else

    nospace = 0

    chars = chars + 1

    End If

    Loop

    ' Calculate amount of characters left

    More = LOS - chars

    ' Display 500 characters within article

    response.write("<p align='left'><small>"&Article&"...</small></p>")

    ' Link to view more of the article

    %>

    <do type="accept" label="More"><go href="NEXT WAP PAGE TO DISPLAY MORE" method="post"><postfield name="id" value="<%=id%>"/><postfield name="more" value="<%=More%>"/></go></do>

    <%

    Else

    ' Display full article

    response.write(Article)

    End If

    To display the remainder on the NEXT WAP PAGE:

    Get the Article strings data again from the database using the id variable and then calculate the remainder by Article = Right(Article,more) then something like

    <p align="left"><small>...<%=Article%></small></p>. Don’t forget to retrieve the id and more variables first.

    Please do not contact me on the above code as I will not reply (I expect you to mess around with the code yourself). If you wish to contact me on updates to the Wapalidate function or job opportunities then please e-mail michael_wright@lineone.net.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

    More Code Examples Articles
    More By aspfree

     

    IBM® developerWorks developerWorks - FREE Tools!


    IBM – Taking Web 2.0 to Work

    You'll get answers to many questions and more from David Barnes, Lead Evangelist for IBM Emerging Internet Technologies. David will discuss aspects of Web 2.0 that bring value to corporations, academia, and government. He'll also discuss IBM's vision around Web 2.0, including the importance of remixability and consumability. The discussion will culminate with examples of various IBM Software Group solutions you can use to get ahead of the Web 2.0 adoption curve.
    FREE! Go There Now!


    NEW! Achieving True Agility -- How process can change the behavior of your tools

    Achieving true agility is a never-ending effort. We will showcase how you can become agile incrementally, a few practices at the time.Which practices should any agile team strive to adopt? What additional practices should you consider based on your needs to scale? Adopting practices are however made much easier with the right tool support. What about if your tools adapt to your practices? We will take a look at how the Jazz technology can be leveraged to make your process change the behavior of your tools.
    FREE! Go There Now!


    NEW! Don't wait! Try the Rational Application Developer (RAD) v7.5 open beta code today

    Download the Rational Application Developer (RAD) v7.5 open beta code and start developing applications for the JEE5 standard which features EJB3.0, JPA, JSF 1.2, JSP 2.1 and Servlet 2.5 standards. When you use this beta you will see how you can increase developer productivity for already existing applications with improved support for refactoring, as well as adding new features to existing applications. In addition, the beta provides tooling for JD Edwards, Oracle, SAP, Siebel and PeopleSoft to improve the developer productivity with these enterprise systems.
    FREE! Go There Now!


    NEW! Download DB2 9.5 for Linux, Unix, and Windows

    Download a free trial version of IBM DB2 9.5 for Linux, UNIX, and Windows. DB2 9 is the result of a five-year development project that transformed traditional (static) database technology into an interactive data server that merges the high performance and ease of use of DB2 with the self-describing benefits of XML.
    FREE! Go There Now!


    NEW! Hello World: Monitor a simple business process using WebSphere Business Monitor V6.0.2

    This tutorial shows new users of IBM WebSphere Business Monitor Version 6.0.2 how to perform the "Hello World" equivalent for monitoring business process applications. It is intended to help you get familiar with the capabilities of the product.
    FREE! Go There Now!


    NEW! Krugle, developerWorks, and code search

    Ken Krugler, co-founder of code search company Krugle, and Laura Merling, vice president of Marketing and Business Development for Krugle, join to talk about the ins and outs of code search and what it means as a new feature for developerWorks users.
    FREE! Go There Now!


    NEW! Project and Portfolio Management Executive Resource Kit

    Portfolio Management is about effectively managing portfolio value by aligning portfolio investments with business goals. This complimentary e-kit provides a collection of materials that can help you understand how IBM Rational enables and automates best practices for improved governance and clear visibility into portfolio and project performance across the entire IT project lifecycle.
    FREE! Go There Now!


    NEW! Trial download: IBM Rational Method Composer V7.2

    Get a free trial download of the latest version of IBM Rational Method Composer V7.2 which helps you deliver customized yet consistent process guidance to your project teams and IT organization, and includes the latest version of IBM Rational Unified Process (RUP), which has provided process guidance to teams since 1996.
    FREE! Go There Now!


    NEW! Trial download: IBM Rational Tester for SOA Quality V7.0.1

    Get a free trial download of the latest version of IBM Rational Tester for SOA Quality V7.0.1, a functional and regression testing tool that enables the creation, comprehension, modification and execution of testing GUI-less Web services.
    FREE! Go There Now!


    NEW! Try the IBM SOA Sandbox for Connectivity

    Visit IBM developerWorks to try the IBM SOA Sandbox for connectivity. The SOA Sandbox for connectivity provides a trial environment with the tooling and components to help you explore how to effectively connect your infrastructure and integrate all of the people, processes and information in your company. Use the hosted sandbox to explore SOA techniques that streamline connecting existing IT assets together, as well as learn how to connect them to new business logic.
    FREE! Go There Now!



    All FREE IBM® developerWorks Tools!

    CODE EXAMPLES ARTICLES

    - Bipartite Graphs
    - Connectivity in Graphs
    - The Ford-Fulkerson Algorithm
    - Critical Paths
    - The Bellman-Ford and Roy-Floyd Algorithms
    - Shortest Path Algorithms in Graphs
    - Minimum Spanning Tree
    - Articulation Edges and Vertexes
    - Circles and Connectivity in Graphs
    - Depth-First Search in Graphs
    - Breadth-First Search in Graphs
    - The Prufer Code and the Floyd-Warshall Algor...
    - An Insight into Graphs
    - Coding a Custom Object with WSC
    - Creating a Custom Object with WSC





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek